2.0.122 • Published 4 years ago
@tix-factory/http v2.0.122
@tix-factory/http
TODO
Example
import http from "http";
import { HttpClient, HttpRequest, httpMethods } from "@tix-factory/http";
const httpClient = new HttpClient();
const httpRequest = new HttpRequest(httpMethods.get, new URL("https://www.roblox.com/users/profile?username=WebGL3D"));
httpClient.send(httpRequest).then(httpResponse => {
let headers = httpResponse.headers.map(header => `${header.name}: ${header.value}`);
console.log(`request finished (${httpResponse.statusCode} ${http.STATUS_CODES[httpResponse.statusCode]})\n\tResponse URL: ${httpResponse.url}\n\t${headers.join("\n\t")}\n\n`, httpResponse.body.toString());
}).catch(console.error);
import { HttpResponse, HttpServer } from "@tix-factory/http";
const httpServer = new HttpServer({
errorHandler: err => {
consolee.error("unexpected exception with request", err);
}
}, httpRequest => {
return new Promise((resolve, reject) => {
if (httpRequest.url.pathname === "/favicon.ico") {
const httpResponse = new HttpResponse(404);
httpResponse.addHeader("Content-Type", "application/json");
httpResponse.body = Buffer.from(JSON.stringify({}));
resolve(httpResponse);
return;
}
setTimeout(() => {
const httpResponse = new HttpResponse(200);
httpResponse.addHeader("Content-Type", "application/json");
httpResponse.body = Buffer.from(JSON.stringify({}));
resolve(httpResponse);
}, 5 * 1000);
});
});
2.0.122
4 years ago
2.0.120
4 years ago
2.0.118
5 years ago
2.0.116
5 years ago
2.0.108
5 years ago
2.0.114
5 years ago
2.0.111
5 years ago
2.0.110
5 years ago
2.0.105
5 years ago
2.0.103
5 years ago
2.0.101
5 years ago
2.0.100
5 years ago
2.0.98
5 years ago
2.0.96
5 years ago
2.0.94
5 years ago
2.0.92
5 years ago
2.0.90
5 years ago
2.0.88
5 years ago
2.0.86
5 years ago
2.0.84
5 years ago
2.0.82
5 years ago
2.0.80
5 years ago
2.0.78
5 years ago
2.0.76
5 years ago
2.0.74
5 years ago
2.0.73
5 years ago
2.0.70
5 years ago
2.0.68
5 years ago
2.0.66
5 years ago
2.0.64
5 years ago
2.0.62
5 years ago
2.0.60
5 years ago
2.0.57
5 years ago
2.0.55
5 years ago
2.0.53
5 years ago
2.0.51
5 years ago
2.0.49
5 years ago
2.0.46
5 years ago
2.0.44
5 years ago
2.0.37
5 years ago
2.0.42
5 years ago
2.0.40
5 years ago
2.0.35
5 years ago
2.0.33
5 years ago
2.0.31
5 years ago
2.0.26
5 years ago
2.0.24
5 years ago
2.0.21
5 years ago
2.0.29
5 years ago
2.0.16
5 years ago
2.0.11
5 years ago
2.0.7
5 years ago