4 examples of 'response.writehead' in JavaScript

Every line of 'response.writehead' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
316writeHead(statusCode, statusMessage, headers) {
317 if (this.headersSent)
318 return;
319
320 if (!headers && typeof statusMessage !== 'string') {
321 headers = statusMessage;
322 statusMessage = undefined;
323 }
324 if (statusCode)
325 this.statusCode = statusCode;
326 if (statusMessage)
327 this.statusMessage = statusMessage;
328
329 if (headers) {
330 for (let name in headers)
331 this.setHeader(name, headers[name]);
332 }
333}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

258writeHead(statusCode, reason, obj) {
259 super.writeHead(statusCode, reason, obj);
260 // we want this._body to be just the body on this.end
261 this._header = '';
262}
225ReaddirCall.prototype.writeHead = function writeHead() {
226 var xdr = this._serialize(XDR.byteLength(this.dir) + 20);
227 xdr.writeString(this.dir);
228 xdr.writeHyper(this.cookie);
229 if (!this.cookieverf) {
230 this.cookieverf = new Buffer(8);
231 this.cookieverf.fill(0);
232 }
233 xdr.writeRaw(this.cookieverf);
234 xdr.writeInt(this.count);
235
236 this.write(xdr.buffer());
237};
39return function writeHead(statusCode) {
40 // set headers from arguments
41 var args = setWriteHeadHeaders.apply(this, arguments);
42
43 // fire listener
44 if (!fired) {
45 fired = true
46 listener.call(this)
47
48 // pass-along an updated status code
49 if (typeof args[0] === 'number' && this.statusCode !== args[0]) {
50 args[0] = this.statusCode
51 args.length = 1
52 }
53 }
54
55 prevWriteHead.apply(this, args);
56}

Related snippets