本文整理匯總了TypeScript中express.Response.removeHeader方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response.removeHeader方法的具體用法?TypeScript Response.removeHeader怎麽用?TypeScript Response.removeHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類express.Response
的用法示例。
在下文中一共展示了Response.removeHeader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
res.end = function(
cbOrChunk?: (() => void)|Buffer|string,
cbOrEncoding?: (() => void)|string,
cb?: () => void): void {
if (ended) {
return;
}
ended = true;
if (shouldTransform()) {
if (Buffer.isBuffer(cbOrChunk)) {
chunks.push(cbOrChunk);
} else if (typeof cbOrChunk === 'string') {
chunks.push(Buffer.from(cbOrChunk, cbOrEncoding as BufferEncoding));
}
const body = Buffer.concat(chunks).toString('utf8');
let newBody = body;
try {
newBody = transformer.transform(req, res, body);
} catch (e) {
console.warn('Error', e);
}
// TODO(justinfagnani): re-enable setting of content-length when we know
// why it was causing truncated files. Could be multi-byte characters.
// Assumes single-byte code points!
// res.setHeader('Content-Length', `${newBody.length}`);
res.removeHeader('Content-Length');
// TODO(aomarks) Shouldn't we call the callbacks?
return _end.call(this, newBody);
} else {
return _end.call(this, cbOrChunk, cbOrEncoding, cb);
}
};
示例2: function
res.end = function(
chunk?: Buffer|string,
cbOrEncoding?: Function|string,
cbOrFd?: Function|string): boolean {
if (ended)
return false;
ended = true;
if (shouldTransform()) {
if (chunk) {
const buffer = (typeof chunk === 'string') ?
new Buffer(chunk, cbOrEncoding as string) :
chunk;
chunks.push(buffer);
}
const body = Buffer.concat(chunks).toString('utf8');
let newBody = body;
try {
newBody = transformer.transform(req, res, body);
} catch (e) {
console.warn('Error', e);
}
// TODO(justinfagnani): re-enable setting of content-length when we know
// why it was causing truncated files. Could be multi-byte characters.
// Assumes single-byte code points!
// res.setHeader('Content-Length', `${newBody.length}`);
res.removeHeader('Content-Length');
return _end.call(this, newBody);
} else {
return _end.call(this, chunk, cbOrEncoding, cbOrFd);
}
};
示例3:
post.gpx(res).catch(err => {
log.error(err);
res.removeHeader(Header.Content.Type);
res.removeHeader(Header.Content.Disposition);
view.notFound(req, res);
});