3 examples of 'express response' in JavaScript

Every line of 'express response' 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
76protected sendResponse(
77 response: HTTPResponse,
78 res: Response,
79 next: NextFunction
80) {
81 const { vary, ...otherHeaders } = response.headers;
82
83 if(vary) {
84 varyLib(res, vary);
85 }
86
87 if(response.status === 406 && !this.config.handleContentNegotiation) {
88 next();
89 return;
90 }
91
92 res.status(response.status || 200);
93
94 Object.keys(otherHeaders).forEach(k => {
95 res.set(k, otherHeaders[k]);
96 });
97
98 if(response.body !== undefined) {
99 res.send(new Buffer(response.body)).end();
100 }
101
102 else {
103 res.end();
104 }
105}
9public setStatusCode(code: number): IResponse {
10 this.res.status(code);
11 return this;
12}
689function Response (req, options) {
690 options = options || {}
691 this.req = req
692 this.xhr = this.req.xhr
693 this.text = this.req.method !='HEAD'
694 ? this.xhr.responseText
695 : null
696 this.setStatusProperties(this.xhr.status)
697 this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders())
698// getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
699// getResponseHeader still works. so we get content-type even if getting
700// other headers fails.
701 this.header['content-type'] = this.xhr.getResponseHeader('content-type')
702 this.setHeaderProperties(this.header)
703 this.body = this.req.method != 'HEAD'
704 ? this.parseBody(this.text)
705 : null
706 }

Related snippets