MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / constructor

Method constructor

modules/network/http/http.js:53–74  ·  view source on GitHub ↗
(dictionary)

Source from the content-addressed store, hash-verified

51
52export class Request {
53 constructor(dictionary) {
54 if (dictionary.socket) {
55 this.socket = dictionary.socket; // server re-using Request
56 return;
57 }
58
59 dictionary = {port: 80, method: "GET", path: "/", Socket, ...dictionary};
60
61 this.method = dictionary.method;
62 this.path = dictionary.path;
63 this.host = dictionary.host ? dictionary.host : dictionary.address;
64 if (dictionary.headers)
65 this.headers = dictionary.headers;
66 if (dictionary.body)
67 this.body = dictionary.body;
68 if (dictionary.response)
69 this.response = dictionary.response;
70 this.state = 0;
71
72 this.socket = new (dictionary.Socket)(dictionary);
73 this.socket.callback = callback.bind(this);
74 }
75
76 read(type, limit) {
77 let available = this.socket.read();

Callers

nothing calls this directly

Calls 1

bindMethod · 0.45

Tested by

no test coverage detected