Main Content

matlab.net.http.field.LocationField Class

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

HTTP Location header field

Description

A LocationField object contains the message uniform resource identifier (URI). The server adds a Location field to a response message to tell you to redirect messages to another URI. The meaning of this field depends on the status code of the response.

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Creation

Description

example

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

Properties

expand all

Header field name, specified as 'Location'.

Attributes:

GetAccess
public
SetAccess
public

URI, specified as a matlab.net.URI object or a string acceptable to the URI constructor.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true

Methods

expand all

Examples

collapse all

This example shows how to read a message URI.

import matlab.net.*;
import matlab.net.http.*;
httpUrl = 'http://requestserver.mathworks.com';
uri = URI(strcat(httpUrl, '/movedPermanently'));
options = HTTPOptions('MaxRedirects', 0); % Disable redirects
req = RequestMessage('GET');
response = req.send(uri, options);
locationField = response.getFields("Location");
disp(locationField)
  LocationField with properties:

     Name: "Location"
    Value: "http://requestserver.mathworks.com/assets/computerVision.jpg"

Version History

Introduced in R2016b