当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Response.getHeader方法代码示例

本文整理汇总了TypeScript中express.Response.getHeader方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Response.getHeader方法的具体用法?TypeScript Response.getHeader怎么用?TypeScript Response.getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在express.Response的用法示例。


在下文中一共展示了Response.getHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Date

    res.end = (chunk?: any, encoding?: string | Function): void => {
        res.end = end;
        res.end(chunk, (encoding as string));

        meta.res = {
            statusCode: res.statusCode,
            responseTime: (new Date() as any) - res.locals.startTime,
        };

        if (resLog.headers) {
            // there are 2 headers that will not appear here:
            // 1. Date: "server date"
            // 2. Connection: "keep-alive"
            // there is an npm package that extracts these 2 headers too but it doesn't make sens to use it just for that
            // npm: https://github.com/watson/http-headers
            meta.res.headers = (res as any)._headers;
        }

        if (resLog.body && chunk) {
            const contentType = res.getHeader("content-type");
            const isJson = typeof contentType === "string" && contentType.indexOf("json") >= 0;
            meta.res.body = bodyToString(chunk, isJson);
        }

        logger.info("http-logger", meta);
    };
开发者ID:lmaran,项目名称:scoala21,代码行数:26,代码来源:httpLogHandler.middleware.ts


注:本文中的express.Response.getHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。