This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page. class


First line of HTTP request message


The RequestLine class represents the first line of a request message. A request line is automatically created when you send or complete a message. You also can create a request line and pass it to the RequestMessage.send method in place of the URI argument.



obj =,requestTarget,protocolVersion) creates a request line with the specified properties. You can omit trailing arguments and use [] to specify any placeholders.

obj = creates a request line by parsing str.

Input Arguments

expand all

Request line, specified as a string or character vector. str consists of 1-3 parts, separated by white space, specifying the Method, RequestTarget, and ProtocolVersion properties.


expand all

Request method, specified as a enumeration or a string or character vector representing a request method. To send a message, set the RequestMessage.Method property or the RequestLine.Method property.

Example: 'GET'



Protocol version, specified as a object or a string acceptable to the constructor.

Example: 'HTTP/1.1'

Target URI, specified as a object or a string or character vector acceptable to the constructor. The RequestTarget value must be consistent with the URI you specify in a request message send or complete method.

RequestTarget contains at least a leading forward slash (/) for the Path property, even if the path is relative or empty.

When using a proxy, RequestTarget is a full URI with Scheme and Authority properties. When not using a proxy, RequestTarget must be an absolute path with an optional Query property. You specify a proxy in an HTTPOptions object.

Example: ''


These methods implement the equivalent MATLAB® functionality for this class.


Request line as character vector


Request line as string


collapse all

Create an HTTP request line to get an image from the Hubble Heritage Project website.

url = '';
reqline = RequestLine('get',url,'HTTP/1.1');
ans = 
"GET HTTP/1.1"

Introduced in R2016b

Was this topic helpful?