Object built-in object

Object HttpRequest

http request message object

Inheritance

Constructor

HttpRequest

HttpRequest constructor to create a new HttpRequest object

1
new HttpRequest();

constant

TEXT

Specify message type 1, which represents a text type

1
const HttpRequest.TEXT = 1;

BINARY

Specify message type 2, which represents a binary type

1
const HttpRequest.BINARY = 2;

Member attributes

response

HttpResponse , get the response message object

1
readonly HttpResponse HttpRequest.response;

method

String, query and set request method

1
String HttpRequest.method;

address

String, query and set the request address

1
String HttpRequest.address;

queryString

String, query and set request query string

1
String HttpRequest.queryString;

cookies

HttpCollection , get the container containing message cookies

1
readonly HttpCollection HttpRequest.cookies;

form

HttpCollection , get the container containing the message form

1
readonly HttpCollection HttpRequest.form;

query

HttpCollection , get the container containing the message query

1
readonly HttpCollection HttpRequest.query;

protocol

String, protocol version information, the allowed format is: HTTP/#.#

1
String HttpRequest.protocol;

headers

HttpCollection , the container that contains the http header in the message, read-only attribute

1
readonly HttpCollection HttpRequest.headers;

keepAlive

Boolean, query and set whether to keep the connection

1
Boolean HttpRequest.keepAlive;

upgrade

Boolean, query and set whether it is an upgrade agreement

1
Boolean HttpRequest.upgrade;

maxHeadersCount

Integer, query and set the maximum number of request headers, the default is 128

1
Integer HttpRequest.maxHeadersCount;

maxBodySize

Integer, query and set the maximum size of the body, in MB, the default is 64

1
Integer HttpRequest.maxBodySize;

socket

Stream , query the source socket of the current object

1
readonly Stream HttpRequest.socket;

value

String, the basic content of the message

1
String HttpRequest.value;

params

NArray, the basic parameters of the message

1
readonly NArray HttpRequest.params;

type

Integer, message type

1
Integer HttpRequest.type;

data

Value, query the data of the message

1
readonly Value HttpRequest.data;

body

SeekableStream , a stream object containing the data part of the message

1
SeekableStream HttpRequest.body;

length

Long, the length of the message data part

1
readonly Long HttpRequest.length;

stream

Stream , the stream object when querying the message readFrom

1
readonly Stream HttpRequest.stream;

lastError

String, query and set the last error of message processing

1
String HttpRequest.lastError;

Member function

hasHeader

Check whether there is a message header with the specified key value

1
Boolean HttpRequest.hasHeader(String name);

Call parameters:

  • name : String, specify the key value to be checked

Return result:

  • Boolean , returns whether the key value exists

firstHeader

Query the first message header of the specified key

1
String HttpRequest.firstHeader(String name);

Call parameters:

  • name : String, specify the key value to be queried

Return result:

  • String , returns the value corresponding to the key value, if it does not exist, returns undefined

allHeader

Query all message headers of the specified key value

1
NObject HttpRequest.allHeader(String name = "");

Call parameters:

  • name : String, specify the key value to be queried, pass an empty string to return the result of all key values

Return result:

  • NObject , returns an array of all values ​​corresponding to the key value, if the data does not exist, returns null

addHeader

Add a message header, adding data does not modify the message header of the existing key value

1
HttpRequest.addHeader(Object map);

Call parameters:

  • map : Object, specify the key-value data dictionary to be added

Add a set of message headers with a specified name, adding data does not modify the message headers of the existing key value

1 2
HttpRequest.addHeader(String name, Array values);

Call parameters:

  • name : String, specify the key value to be added
  • values : Array, specify a set of data to be added

Add a message header, adding data does not modify the message header of the existing key value

1 2
HttpRequest.addHeader(String name, String value);

Call parameters:

  • name : String, specify the key value to be added
  • value : String, specify the data to be added

setHeader

Set a message header, the setting data will modify the first value corresponding to the key value, and clear the other message headers with the same key value

1
HttpRequest.setHeader(Object map);

Call parameters:

  • map : Object, specify the key value data dictionary to be set

Set a set of message headers with a specified name. The setting data will modify the value corresponding to the key value and clear the rest of the message headers with the same key value

1 2
HttpRequest.setHeader(String name, Array values);

Call parameters:

  • name : String, specify the key value to be set
  • values : Array, specify a set of data to be set

Set a message header, the setting data will modify the first value corresponding to the key value, and clear the other message headers with the same key value

1 2
HttpRequest.setHeader(String name, String value);

Call parameters:

  • name : String, specify the key value to be set
  • value : String, specify the data to be set

removeHeader

Delete all message headers of the specified key value

1
HttpRequest.removeHeader(String name);

Call parameters:

  • name : String, specify the key to be deleted

read

Read data of the specified size from the stream, this method is an alias of the corresponding method of body

1
Buffer HttpRequest.read(Integer bytes = -1) async;

Call parameters:

  • bytes : Integer, specify the amount of data to be read, the default is to read data blocks of random size, the size of the data read depends on the device

Return result:

  • Buffer , returns the data read from the stream, if there is no data to read, or the connection is interrupted, it returns null

readAll

Read all remaining data from the stream, this method is an alias of the corresponding method of body

1
Buffer HttpRequest.readAll() async;

Return result:

  • Buffer , returns the data read from the stream, if there is no data to read, or the connection is interrupted, it returns null

write

Write the given data, this method is the alias of the corresponding method of body

1
HttpRequest.write(Buffer data) async;

Call parameters:

  • data : Buffer , given the data to be written

json

Write the given data in JSON encoding

1
Value HttpRequest.json(Value data);

Call parameters:

  • data : Value, given the data to be written

Return result:

  • Value , this method will not return data

Parse the data in the message in JSON encoding

1
Value HttpRequest.json();

Return result:

  • Value , returns the parsed result

end

Set the current message processing to end, and the Chain processor will not continue subsequent transactions

1
HttpRequest.end();

isEnded

Query whether the current message is over

1
Boolean HttpRequest.isEnded();

Return result:

  • Boolean , return true at the end

clear

Clear the content of the message

1
HttpRequest.clear();

sendTo

Send a formatted message to the given stream object

1
HttpRequest.sendTo(Stream stm) async;

Call parameters:

  • stm : Stream , specifies the stream object that receives formatted messages

readFrom

Read the formatted message from the given cache stream object, and parse the filling object

1
HttpRequest.readFrom(Stream stm) async;

Call parameters:

  • stm : Stream , specifies the stream object for reading formatted messages

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String HttpRequest.toString();

Return result:

  • String , returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value HttpRequest.toJSON(String key = "");

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable