@@ -6,38 +6,38 @@ import { findIndexInUint8Array, uint8ArrayToStr } from '#src/utils/generics.ts'
66import { REDACTION_CHAR_CODE } from '#src/utils/redactions.ts'
77
88export type HttpRequest = {
9- method : string
10- url : string
11- protocol : string
12- headers : IncomingHttpHeaders
13- body ?: Uint8Array
9+ method : string
10+ url : string
11+ protocol : string
12+ headers : IncomingHttpHeaders
13+ body ?: Uint8Array
1414}
1515
1616export type HttpResponse = {
17- statusCode : number
18- statusMessage : string
19- headers : IncomingHttpHeaders
20- body : Uint8Array
21- headersComplete : boolean
22- complete : boolean
23-
24- /**
25- * Index of the first byte of the status line
26- */
27- statusLineEndIndex ?: number
28- /**
29- * Index of the first byte of the body
30- * in the complete response
31- */
32- bodyStartIndex ?: number
33- /**
34- * If using chunked transfer encoding,
35- * this will be set & contain indices of each
36- * chunk in the complete response
37- */
38- chunks ?: ArraySlice [ ]
39-
40- headerIndices : Map < string , ArraySlice >
17+ statusCode : number
18+ statusMessage : string
19+ headers : IncomingHttpHeaders
20+ body : Uint8Array
21+ headersComplete : boolean
22+ complete : boolean
23+
24+ /**
25+ * Index of the first byte of the status line
26+ */
27+ statusLineEndIndex ?: number
28+ /**
29+ * Index of the first byte of the body
30+ * in the complete response
31+ */
32+ bodyStartIndex ?: number
33+ /**
34+ * If using chunked transfer encoding,
35+ * this will be set & contain indices of each
36+ * chunk in the complete response
37+ */
38+ chunks ?: ArraySlice [ ]
39+
40+ headerIndices : Map < string , ArraySlice >
4141 /**
4242 * index of separator \r\n\r\n between headers and body
4343 */
@@ -58,7 +58,7 @@ export function makeHttpResponseParser() {
5858 body : new Uint8Array ( ) ,
5959 complete : false ,
6060 headersComplete : false ,
61- headerIndices : new Map < string , ArraySlice > ( ) ,
61+ headerIndices :new Map < string , ArraySlice > ( ) ,
6262 headerEndIdx : 0
6363 }
6464
@@ -70,9 +70,9 @@ export function makeHttpResponseParser() {
7070 return {
7171 res,
7272 /**
73- * Parse the next chunk of data
74- * @param data the data to parse
75- */
73+ * Parse the next chunk of data
74+ * @param data the data to parse
75+ */
7676 onChunk ( data : Uint8Array ) {
7777 // concatenate the remaining data from the last chunk
7878 remaining = concatenateUint8Arrays ( [ remaining , data ] )
@@ -110,8 +110,8 @@ export function makeHttpResponseParser() {
110110 const [ key , value ] = line . split ( ': ' )
111111 res . headers [ key . toLowerCase ( ) ] = value
112112 res . headerIndices [ key . toLowerCase ( ) ] = {
113- fromIndex : currentByteIdx - line . length - HTTP_HEADER_LINE_END . length ,
114- toIndex : currentByteIdx - HTTP_HEADER_LINE_END . length
113+ fromIndex :currentByteIdx - line . length - HTTP_HEADER_LINE_END . length ,
114+ toIndex :currentByteIdx - HTTP_HEADER_LINE_END . length
115115 }
116116 } else {
117117 throw new Error ( 'got more data after response was complete' )
@@ -166,9 +166,9 @@ export function makeHttpResponseParser() {
166166 }
167167 } ,
168168 /**
169- * Call to prevent further parsing; indicating the end of the request
170- * Checks that the response is valid & complete, otherwise throws an error
171- */
169+ * Call to prevent further parsing; indicating the end of the request
170+ * Checks that the response is valid & complete, otherwise throws an error
171+ */
172172 streamEnded ( ) {
173173 if ( ! res . headersComplete ) {
174174 throw new Error ( 'stream ended before headers were complete' )
0 commit comments