當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Response.removeHeader方法代碼示例

本文整理匯總了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);
      }
    };
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例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);
      }
    };
開發者ID:iblancasa,項目名稱:polyserve,代碼行數:32,代碼來源:transform-middleware.ts

示例3:

 post.gpx(res).catch(err => {
    log.error(err);
    res.removeHeader(Header.Content.Type);
    res.removeHeader(Header.Content.Disposition);
    view.notFound(req, res);
 });
開發者ID:Trail-Image,項目名稱:blog,代碼行數:6,代碼來源:map.ts


注:本文中的express.Response.removeHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。