Fathom v0.2

component fathom.proto.http

This component provides an API for the HTTP protocol.

Methods

Methods Returns Description
create( ) void static This function creates and returns an HTTP object.
getCertificateChain( uri, callback ) void static This function gets a certificate chain information for the specified uri.

Parameters:

  • uri <string> This is uri for which certificate information is desired.
  • callback <function> This is a callback that is invoked when then complete certificate chain information is available. The information is available as a JSON string.
open( httpObj, url, lookup, IP ) void static This function opens an HTTP connection to the specified URI/IP.

Parameters:

  • httpObj <object> This is the HTTP object created using the 'create' API.
  • url <string> This is the URL to be fetched.
  • lookup <function> This is a lookup function to resolve the domain of the given url and return the associated IP address.
  • IP <string> This is the IP address of the host. If the IP address is provided then url and lookup function are not used. IP address can be nullbut then both the url and lookup functions must be provided to establish the conenction.
receive( httpObj, recvCallback ) void static This function gets an HTTP response.

Parameters:

  • httpObj <object> This is the HTTP object created using the 'create' API.
  • recvCallback <function> This function is invoked when the response headers are available or chunked (or complete) response is available. This callback's signature is callback(type, data), where type can be 1 for HTTP headers, 3 for chunked response and 4 for complete response.
send( httpObj, method, data, headers ) void static This function sends an HTTP request to the the specified host.

Parameters:

  • httpObj <object> This is the HTTP object created using the 'create' API.
  • method <string> This is the HTTP method to be used -- GET, POST, etc.
  • data <string> This is the query string for the request. It can null in case of GET.
  • headers <object> This represents the HTTP headers associated with the request.