node-httpx
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -122,2 +122,1 @@ /* | ||
module.exports = exports = httpx; | ||
/*find alternate debugger*/ |
{ | ||
"name": "node-httpx", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Provides a TLS-agnostic HTTP server and eliminates the redundancy in providing both secure and insecure servers.", | ||
@@ -5,0 +5,0 @@ "main": "httpx.js", |
@@ -107,3 +107,77 @@ # node-httpx | ||
httpx.request is for running http-style requests via httpx. By default, when a request is initiated, first the module tries to use https.request. If that fails for some reason, plain http.request is used instead with the same configuration. If that fails, an error is thrown. | ||
Example: | ||
``` | ||
var options = {}; | ||
options.hostname = "encrypted.google.com"; | ||
options.path = "/"; | ||
options.method = "get"; | ||
var googleRequest = httpx.request(options, function(res){ | ||
var answer = ""; | ||
res.on("data", function(d){ | ||
answer += d; | ||
}); | ||
res.on("end", function(){ | ||
console.log(answer); | ||
}); | ||
}); | ||
googleRequest.write("text"); | ||
googleRequest.end(); | ||
``` | ||
### httpx.request.write(payload) | ||
This function is used to write context to a working httpx request object. This should not be used in httpx.get. | ||
### httpx.request.end() | ||
This function states that everything has been sent that will be sent for this request. This should not be used in httpx.get. | ||
### httpx.request config object | ||
* hostname : either a valid domain or IP address of the server being requested. REQUIRED. | ||
* path : the part of the URL that's not the port, hostname, or protocol. REQUIRED. | ||
* method : the HTTP method to be used. Default: "get". | ||
* httpsPort: the port for https requests. Default: 443. | ||
* httpPort: the port for http requests. Default: 80. | ||
Note: anything setting that exists in node.http or node.https also exists in these settings. These are just the only ones the code explicitly interacts with. | ||
### httpx.request callback function | ||
``` | ||
function (res) { | ||
} | ||
``` | ||
Res is an event emmiter that is emmited once per request. | ||
### httpx.requeset.response.err | ||
``` | ||
res.on("error", errObject); | ||
``` | ||
This is emmited when both https.request and http.request failed with the given configuration. It contains the error object from node.http. | ||
### httpx.requeset.response.data | ||
``` | ||
res.on("data", segment); | ||
``` | ||
This is emmited when a section of the response arrives properly at the client. Segment is usually a string. | ||
### httpx.requeset.response.end | ||
``` | ||
res.on("end"); | ||
``` | ||
This is emmited when there is no more data that will come in the response. | ||
## httpx.get | ||
This is httpx.request, but the request is assumed to be a GET request, the payload is automatically empty, and the transmission ended automatically. The event listeners, configurations, and callbacks are identical. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28631
183