Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

matlab.net.http.ResponseMessage class

Package: matlab.net.http
Superclasses: matlab.net.http.Message

HTTP response message

Description

The ResponseMessage class formats HTTP response messages returned by a server. The RequestMessage.send method creates a response message.

Properties

expand all

Status line from server, specified as a matlab.net.http.StatusLine object.

Attributes:

Dependenttrue

HTTP status code, specified as a matlab.net.http.StatusCode object. Same as the StatusLine.StatusCode property.

Attributes:

Dependenttrue
GetAccesspublic
SetAccessimmutable

Message header, specified as a matlab.net.http.HeaderField object or a vector of HeaderField objects. When you set the Header property, MATLAB® checks the fields of the header to ensure that they are appropriate for the message type. The RequestMessage send and complete methods fill in any required header fields for a properly formed request.

Message body, specified as a matlab.net.http.MessageBody object or data acceptable to the MessageBody constructor. By default, Body is empty (set to []). A request message containing a Body property normally uses a method such as 'PUT' or 'POST', not the default value 'GET', but this syntax is not enforced.

In a completed or received message, if the message has a ContentTypeField header field, then the MessageBody.ContentType property is set to that value. Otherwise, ContentType is unchanged or empty.

Whether message is completed, specified as true or false. A true value means that the message was completed. Methods that return messages set the Completed property to true when:

  • The Body or Body.Data properties are empty.

  • The Body.Payload property contains the raw data.

Attributes:

Transienttrue

Data Types: logical

Methods

completeProcess or reprocess response payload Content-Type

Attributes

Sealedtrue

Examples

expand all

Send a message to the Hubble Heritage website requesting an image of Jupiter.

Format an HTTP request message and display the Content-Type of the response message body. The server returns a JPEG image.

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI('http://heritage.stsci.edu/2007/14/images/p0714aa.jpg');
r = send(request,uri);
r.Body.ContentType
ans = 

  MediaType with properties:

          Type: "image"
       Subtype: "jpeg"
    Parameters: []
     MediaInfo: "image/jpeg"
        Weight: []

Display the image using the imshow function. MATLAB resizes the image to fit on the screen.

warning('off','Images:initSize:adjustingMag');
imshow(r.Body.Data)

Introduced in R2016b

Was this topic helpful?