IoT.js provides HTTP to support HTTP server and client enabling users to receive/send HTTP request easily.
requestListener: Function- Return:
http.Serverinstance
options: Objectcallback: Function- Return:
http.ClientRequestinstance
options: Objectcallback: Function- Return:
http.ClientRequestinstance
Same as http.request except that http.get automatically call req.end() at the end.
request: http.IncomingMessageinstance.response: http.ServerResponseinstance. After request header is parsed, this event will be fired.
This event is emitted when new TCP connection is established.
This event is emitted when server is closed.
port: Numberhost: Stringbacklog: Numbercallback: Function
Wait for new TCP connection with specified port and hostname. If no hostname is provided, server accepts any IP address.
backlog is maximum pending connections. Default backlog length is 511.
callback will be called when server has been bound.
callback: Function
Stop accepting new connection to this server. However, the existing connections are preserved. When server is finally closed after all connections are closed, a callback is called.
ms: Numbercb: Function
Registers cb for 'timeout' event and sets socket's timeout value to ms. This event will be triggered by the underlying socket's 'timeout' event.
If cb is not provided, the socket will be destroyed automatically after timeout. If you provide cb, you should handle the socket's timeout.
Default timeout for server is 2 minutes.
Server's timeout value. Default value is 2 minutes.
response: http.IncomingMessageinstance
This event is emitted when server's response header is parsed. http.IncomingMessage object is passed as argument to handler.
Net.socketinstance
This event is emitted when a socket is assigned to this request. Net.socket object is passed as argument to handler.
After response header is parsed, this event will be fired.
data: Buffer|Stringcallback: Function
Sends data as a request body. callback will be called when data is flushed.
data: Buffer|Stringcallback: Function
Finishes sending the request.
If data is provided, it sends data first, and finishes.
If callback is specified, it is called when the request stream is finished.
ms: Numbercb: Function
Registers cb for 'timeout' event and set socket's timeout value to ms. This event will be triggered by the underlying socket's 'timeout' event.
If cb is not provided, the socket will be destroyed automatically after timeout. If you provides cb, you should handle the socket's timeout.
This event is fired when no more data to be sent.
When underlying connection is closed, 'close' event is emitted.
This event is emitted when the response has been sent. It does not guarantee that client has received data yet.
statusCode: NumberstatusMessage: Stringheaders: Object
Sets response's header. headers is a map between field and value in header.
name: Stringvalue:
Sets response's header field(name) to value. If the field exists, it overwrites the existing value.
name: String
Returns name field of response's header
name: String
Removes name field from response's header
data: Buffer|Stringcallback: Function
Sends data as a response body. callback will be called when data is flushed.
data: Buffer|Stringcallback: Function
Finishes sending the response.
If data is provided, it sends data first, and finishes.
If callback is specified, it is called when the response stream is finished.
ms: Numbercb: Function
Registers cb for 'timeout' event and set socket's timeout value to ms. This event will be triggered by the underlying socket's 'timeout' event.
http.IncomingMessage inherits Stream.readable
This event is fired when no more data to be received.
When underlying connection is closed, 'close' event is emitted.
ms: Numbercb: Function
Registers cb for 'timeout' event set socket's timeout value to ms. This event will be triggered by the underlying socket's 'timeout' event.
HTTP header object.
Requests method as String
Requests URL as String
HTTP response status code as Number of 3-digit.
HTTP response status message as String
Underlying socket