Main Content

matlab.net.http.field.HTTPDateField Class

Namespace: matlab.net.http.field
Superclasses: matlab.net.http.HeaderField

HTTP header field containing date

Description

An HTTPDateField object is an HTTP header field containing a date. The fields implemented by this class contain a single date in standard HTTP date format.

Creation

Description

obj = matlab.net.http.field.HTTPDateField(name) creates an HTTP date header field with the Name property set to name.

example

obj = matlab.net.http.field.HTTPDateField(name,value) sets the Value property to value.

Properties

expand all

Date field name, specified as a string of one of these values: 'Date', 'Expires', 'Retry-After', 'Accept-Datetime', 'Last-Modified', or 'If-Modified-Since'.

To create a Date field, use the matlab.net.http.field.DateField subclass.

Attributes:

GetAccess
public
SetAccess
public

Date, specified as a datetime object or a string in a valid HTTP date format as specified in RFC 7231 Semantics and Content, section 7.1.1.1. Date/Time Formats on the RFC Editor website. If a datetime object does not have a time zone, then it is assumed to be local.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true

Methods

expand all

Examples

collapse all

This example shows how to read the HTTP date field in a message.

import matlab.net.*;
import matlab.net.http.*;
import matlab.net.http.field.*;

httpsUrl = 'https://requestserver.mathworks.com';
uri = URI(strcat(httpsUrl, '/assets/computerVision.jpg'));
headers = DateField(datetime("today"));
req = RequestMessage('GET', headers);
response = req.send(uri);
httpDateField = response.getFields("Last-Modified");
disp(httpDateField)
  HTTPDateField with properties:

     Name: "Last-Modified"
    Value: "Fri, 02 Apr 2021 20:14:03 GMT"

Version History

Introduced in R2016b