Main Content

matlab.net.http.field.DateField class

Package: matlab.net.http.field
Superclasses: matlab.net.http.HeaderField, matlab.net.http.field.HTTPDateField

HTTP Date header field

Description

A DateField object represents an HTTP Date header field. A Date field is an optional field that represents the date and time a request or a response message was originally sent. If you do not specify a Date field in a request message, then MATLAB® inserts one when you send it. For more information about this field, see RFC 7231 Semantics and Content, section 7.1.1.2 Date on the Internet Engineering Task Force (IETF®) website.

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Creation

Description

example

obj = matlab.net.http.field.DateField(value) creates a Date header field with the Value property set to value.

obj = matlab.net.http.field.DateField sets the field value to the current date and time.

Properties

expand all

Header field name, specified as 'Date'.

Attributes:

GetAccess
public
SetAccess
public

Date and time, specified as a datetime object or a string in a valid HTTP date format. The default is the current date and time. Value must not be in the future. If the time zone is missing, then the local time zone is assumed. The datetime Format property is ignored.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true

Methods

expand all

Examples

collapse all

This example shows how to read the 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);
[~, completedRequest, ~] = req.send(uri);
dateField = completedRequest.getFields("Date");
disp(dateField)
  DateField with properties:

     Name: "Date"
    Value: "Wed, 28 Apr 2021 04:00:00 GMT"

Version History

Introduced in R2016b

See Also