| 49 | |
| 50 | export class Client { |
| 51 | constructor(dictionary) { |
| 52 | // port, host, address, path (everything after port) |
| 53 | this.path = dictionary.path ?? "/"; |
| 54 | this.host = dictionary.host ?? dictionary.address; |
| 55 | this.headers = dictionary.headers ?? []; |
| 56 | this.protocol = dictionary.protocol; |
| 57 | this.state = 0; |
| 58 | this.flags = 0; |
| 59 | |
| 60 | if (dictionary.socket) |
| 61 | this.socket = dictionary.socket; |
| 62 | else { |
| 63 | dictionary.port ??= 80; |
| 64 | if (dictionary.Socket) |
| 65 | this.socket = new dictionary.Socket(Object.assign({}, dictionary.Socket, dictionary)); |
| 66 | else |
| 67 | this.socket = new Socket(dictionary); |
| 68 | } |
| 69 | this.socket.callback = callback.bind(this); |
| 70 | this.doMask = true; |
| 71 | } |
| 72 | |
| 73 | write(message) { |
| 74 | //@@ implement masking |