File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -165,5 +165,17 @@ class SwifterTestsHttpParser: XCTestCase {
165165 resp = try ? parser. readHttpRequest ( TestSocket ( " GET / HTTP/1.0 \n Header1: 1 \n Header2: 2 \n Content-Length: 0 \n \n " ) )
166166 XCTAssertEqual ( resp? . headers [ " header1 " ] , " 1 " , " Parser should extract multiple headers from the request. " )
167167 XCTAssertEqual ( resp? . headers [ " header2 " ] , " 2 " , " Parser should extract multiple headers from the request. " )
168+
169+ resp = try ? parser. readHttpRequest ( TestSocket ( " GET https://www.example.com/some/path?subscript_query[]=1&subscript_query[]=2 HTTP/1.0 \n Content-Length: 10 \n \n 1234567890 " ) )
170+ let queryPairs = resp? . queryParams ?? [ ]
171+ XCTAssertEqual ( queryPairs. count, 2 )
172+ XCTAssertEqual ( queryPairs. first? . 0 , " subscript_query[] " )
173+ XCTAssertEqual ( queryPairs. first? . 1 , " 1 " )
174+ XCTAssertEqual ( queryPairs. last? . 0 , " subscript_query[] " )
175+ XCTAssertEqual ( queryPairs. last? . 1 , " 2 " )
176+ XCTAssertEqual ( resp? . method, " GET " , " Parser should extract HTTP method name from the status line. " )
177+ XCTAssertEqual ( resp? . path, " /some/path " , " Parser should extract HTTP path value from the status line. " )
178+ XCTAssertEqual ( resp? . headers [ " content-length " ] , " 10 " , " Parser should extract Content-Length header value. " )
179+
168180 }
169181}
You can’t perform that action at this time.
0 commit comments