HTTP protocol implementation using fathom sockets.
NOTE, you should use the built-in browser xmlhttprequest API
for fetching HTTP resources, this implementation provides just a basic
support of HTTP for testing/measurement purposes only.
Methods
(static) close(callback, id)
This function closes the HTTP connection.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | The return callback. Returns an object with error field in case of failure. |
id |
integer | The HTTP object id returned from the 'create' API. |
(static) create(callback, ip, port)
This function creates an HTTP protocol object
and connects to the given server.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | The return callback. Returns the protocol object id or an object with error field in case of failure. |
ip |
string | The server IP. |
port |
integer | The server port (default 80). |
(static) receive(callback, id)
Receive HTTP response.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | The return callback. Returns the response or an object with error field in case of failure. |
id |
integer | The HTTP object id returned from the 'create' API. |
(static) send(callback, id, method, path, headers, data)
Send HTTP request.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | The return callback. Returns an object with error field in case of failure. |
id |
integer | The HTTP object id returned from the 'create' API. |
method |
string | This is the HTTP method to be used -- GET, POST, etc. |
path |
string | The resource name to fetch. |
headers |
object | This represents the HTTP headers associated with the request. |
data |
string | This is the query string for the request. It can null in case of GET. |