1 | /*!
|
2 | * Copyright 2021 Google LLC
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | /// <reference types="node" />
|
17 | import * as http from 'http';
|
18 | export declare type RawHttpRequest = http.IncomingMessage & CloudLoggingHttpRequest;
|
19 | export interface CloudLoggingHttpRequest {
|
20 | requestMethod?: string;
|
21 | requestUrl?: string;
|
22 | requestSize?: number;
|
23 | status?: number;
|
24 | responseSize?: number;
|
25 | userAgent?: string;
|
26 | remoteIp?: string;
|
27 | serverIp?: string;
|
28 | referer?: string;
|
29 | latency?: {
|
30 | seconds: number;
|
31 | nanos: number;
|
32 | };
|
33 | cacheLookup?: boolean;
|
34 | cacheHit?: boolean;
|
35 | cacheValidatedWithOriginServer?: boolean;
|
36 | cacheFillBytes?: number;
|
37 | protocol?: string;
|
38 | }
|
39 | /**
|
40 | * Abstraction of http.IncomingMessage used by middleware implementation.
|
41 | */
|
42 | export interface ServerRequest extends http.IncomingMessage {
|
43 | originalUrl: string;
|
44 | }
|
45 | /**
|
46 | * makeHttpRequestData turns raw incoming HTTPRequests into structured
|
47 | * HTTPRequest objects interpreted by Cloud Logging.
|
48 | *
|
49 | * @param req
|
50 | * @param res
|
51 | * @param latencyMilliseconds
|
52 | */
|
53 | export declare function makeHttpRequestData(req: ServerRequest | http.IncomingMessage, res?: http.ServerResponse, latencyMilliseconds?: number): CloudLoggingHttpRequest;
|
54 | /**
|
55 | * isRawHttpRequest detects whether a request object extends the
|
56 | * http.IncomingMessage class. It should return true on HTTP compliant requests
|
57 | * and all requests created by an http.Server.
|
58 | *
|
59 | * @param req
|
60 | */
|
61 | export declare function isRawHttpRequest(req?: any): req is RawHttpRequest;
|