matlab.net.http.RequestMessage class
包裹:matlab.net.http
超类:matlab.net.http.Message
HTTP request message
Description
使用requestMessage
班级以格式化HTTP请求消息,以发送到服务器进行处理。使用send
发送消息的方法,或complete
method to validate the message before sending. These methods fill in any necessary header fields and other message properties.
创建
Description
obj = matlab.net.http.RequestMessage
创建具有默认值的请求消息。发送或完成消息时,默认方法
property isrequestMethod.get
。
obj = matlab.net.http.RequestMessage(method,header,body)
specifies one or more optional messageproperties。您可以省略拖延论点并使用[]
指定任何占位符。
obj = matlab.net.http.RequestMessage(requestLine,header,body)
sets therequestLine
财产为requestLine
。如果需要控制请求行的内容,请使用此语法。例如,要明确将消息发送到代理,请设置requestline.requesttarget
属性到完整的URI。否则,MATLAB根据您的代理设置选择代理send
方法设置RequestTarget
到the小路
URI的财产。
obj = matlab.net.http.RequestMessage(requestLine,header,provider)
从一个获取消息主体数据matlab.net.http.io.ContentProvider
。
特性
requestLine
-请求行
matlab.net.http.requestline
目的|细绳|character vector
请求行,,,,specified as amatlab.net.http.requestline
对象,或包含方法,目标和协议版本的字符串或字符向量。当您根据指定的方法和URI发送消息时,将自动创建此行。如果您明确设置此属性,则将其内容用作请求行。该值可能设置为requestLine
目的or to a string which is parsed and converted to arequestLine
目的。
Example:'获取http/1.1'
一种ttributes:
GetAccess |
public
|
setAccess |
public
|
Dependent |
true
|
方法
-Request method
[]
(默认)|matlab.net.http.requestmethod
枚举|细绳|character vector
Request method, specified as amatlab.net.http.requestmethod
枚举or a string or character vector representing a request method. To send a message, set therequestMessage。方法
属性或requestline.method
财产。
Example:'得到'
一种ttributes:
GetAccess |
public
|
setAccess |
public
|
Dependent |
true
|
标题
-消息头
[]
(默认)|matlab.net.http.HeaderField
目的
消息头,,,,specified as amatlab.net.http.HeaderField
对象或向量Headerfield
对象。当您设置标题
财产,Matlab®checks the fields of the header to ensure that they are appropriate for the message type. TherequestMessage
send
andcomplete
methods fill in any required header fields for a properly formed request.
一种ttributes:
GetAccess |
public
|
setAccess |
public
|
Body
-Message body
[]
(默认)|matlab.net.http.messagebody
目的|matlab.net.http.io.ContentProvider
Message body, specified as amatlab.net.http.messagebody
目的,,,,matlab.net.http.io.ContentProvider
,,,,or data acceptable to theMessageBody
constructor. By default,Body
是空的(设置为[]
)。包含一个的请求消息Body
属性通常使用诸如'PUT'
or'邮政'
,不是默认值'得到'
,,,,but this convention is not enforced.
In a completed or received message, if the message has aContentTypefield
header field, then theMessageBody.ContentType
property is set to that value. Otherwise,ContentType
不变或空。
一种ttributes:
GetAccess |
public
|
setAccess |
public
|
Completed
-消息是否完成
错误的
(默认)|true
消息是否完成,指定为true
or错误的
。一种true
价值意味着消息已完成。
验证消息的方法(requestMessage。send
andrequestMessage.complete
) set theCompleted
财产为true
后:
Determining that the message is valid.
Completing processing, such as adding required header fields and converting the data.
如果属性为真,那么这些方法不会修改消息,并且send
方法在不检查有效性的情况下发送消息。此后对此消息的任何更改都改变了Completed
property back to错误的
。
To send arbitrary headers and data in a request message, setCompleted
到true
防止send
修改消息的方法。您仍然可以使用complete
验证消息的方法,但是send
method sends it whether it is valid.
如果请求消息包含数据(Body.Data
属性不是空的),然后Completed
is set totrue
only ifBody.Payload
contains the raw data. In a response message, the payload is set only if you specify theHTTPOptions.SavePayload
财产。
一种ttributes:
GetAccess |
public
|
setAccess |
public
|
短暂的 |
true
|
数据类型:逻辑
StartLine
-Message start line
matlab.net.http.startline
方法s
公共方法
complete |
Validate and complete HTTP request message without sending |
send |
Send HTTP request message and receive response |
addFields |
一种dd fields to message header |
changeFields |
更改消息标题中的现有字段 |
Getfields |
Return message header fields matching name or class |
删除场 |
从消息标题中删除字段 |
更换场 |
更改或将字段添加到消息标题中 |
显示 |
Display or return formatted version of message |
Specialized Operators and Functions
这些方法专门为本类中的对象提供标准MATLAB操作员和功能。
细绳 |
Message If 字符串是发送或接收时消息的外观的大致表示。 Use for logging, diagnostics, or debugging. For a formatted version of messages, use |
char |
如同 |
是平等的 |
Returns |
Examples
创建HTTP请求消息
Format an HTTP message requesting a server to add text to a website. This example only formats the message and does not send the data.
一种dd content to the message body.
data =“要发送的数据”;body = matlab.net.http.messagebody(data);Body.Show
Data to send
Create a Content-Type header field describing the data type of the body.
contentTypeField = matlab.net.http.field.ContentTypeField(“文字/普通”);
Create an Accept header field specifying the data types acceptable in the response message.
type1 = matlab.net.http.MediaType('text/*');type2 = matlab.net.http.mediatype('应用程序/json',,,,'Q',,,,'.5');acceptfield = matlab.net.http.field.acceptfield([type1 type2]);
创建一个包含两个标头字段的请求标题。
header = [acceptfield contentTypefield];
指定此消息是一个PUT请求。
method = matlab.net.http.RequestMethod.PUT;
创建请求消息并显示内容。
请求= matlab.net.http.RequestMessage(方法,标头,车身);显示(请求)
PUT Accept: text/*, application/json; q=.5 Content-Type: text/plain Data to send
一种pri esempio
Si Discone di Una版本di Questo Esempio。Desideri Aprire Questo Esempio con le tue modifiche?
Comando Matlab
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui Il comando inserendolo nella finestra di comando matlab。我浏览网络非支持者我comandi 金宝appmatlab。
Select a Web Site
选择一个网站以获取可用的翻译内容,并查看本地事件和优惠。根据您的位置,我们建议您选择:。
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
一种mericas
- 一种mérica Latina(Español)
- Canada(English)
- United States(English)