jira-importer opened a new issue, #1158: URL: https://github.com/apache/httpcomponents-core/issues/1158
**[Molnár Gergely](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=gergelymolnarpro)** opened **[HTTPCORE-633](https://issues.apache.org/jira/browse/HTTPCORE-633?redirect=false)** and commented Fail to read correct a header value: Connection: Keep-Alive if the puffer size of the SessionOutputBufferImpl is not 1 (e.g.: 16) Existing parser test: https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestRequestParser.java No existing writer test!! Code: ```java public class HttpCoreApiIT { @Test public void parseWriteTest() throws Exception { // ----------- prepare parse -------- String rawGet = "GET /home.html HTTP/1.1\r\n" + "User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)\r\n" + "Host: example.com\r\n" + "Accept-Language: en-us\r\n" + "Accept-Encoding: gzip, deflate\r\n" + "Connection: Keep-Alive\r\n" + "\r\n"; int bufferSize = 16; SessionInputBuffer inBuffer = new SessionInputBufferImpl(bufferSize, StandardCharsets.US_ASCII.newDecoder()); HttpMessageParser<ClassicHttpRequest> reqParser = new DefaultHttpRequestParser(); Charset charset = StandardCharsets.US_ASCII; // try ClassicHttpRequest request = reqParser.parse(inBuffer, new ByteArrayInputStream(rawGet.getBytes(StandardCharsets.UTF_8))); // test assertEquals("GET", request.getMethod()); assertEquals("/home.html", request.getPath()); assertEquals(5, request.getHeaders().length); assertEquals("example.com", request.getHeader("host").getValue()); assertEquals("en-us", request.getHeader("Accept-Language").getValue()); assertEquals("gzip, deflate", request.getHeader("Accept-Encoding").getValue()); assertEquals("Mozilla/4.0 (compatible; MSIE5.01; Windows NT)", request.getHeader("User-Agent").getValue()); assertEquals("Keep-Alive", request.getHeader("Connection").getValue()); // ----------- prepare write -------- SessionOutputBuffer outBuffer = new SessionOutputBufferImpl(bufferSize, charset.newEncoder()); HttpMessageWriter<ClassicHttpRequest> reqWriter = new DefaultHttpRequestWriter(); // try ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); reqWriter.write(request, outBuffer, outputStream); //outBuffer.flush(outputStream); // not documented, but needed // prepare test with tested parser SessionInputBuffer otherInBuffer = new SessionInputBufferImpl(bufferSize, charset.newDecoder()); ClassicHttpRequest otherRequest = reqParser.parse(otherInBuffer, new ByteArrayInputStream(outputStream.toByteArray())); outputStream.close(); // test assertEquals("GET", otherRequest.getMethod()); assertEquals("/home.html", otherRequest.getPath()); assertEquals(5, otherRequest.getHeaders().length); assertEquals("example.com", otherRequest.getHeader("host").getValue()); assertEquals("en-us", otherRequest.getHeader("Accept-Language").getValue()); assertEquals("gzip, deflate", otherRequest.getHeader("Accept-Encoding").getValue()); assertEquals("Mozilla/4.0 (compatible; MSIE5.01; Windows NT)", otherRequest.getHeader("User-Agent").getValue()); assertEquals("Keep-Alive", otherRequest.getHeader("Connection").getValue()); } } ``` outBuffer.flush(outputStream); solve the problem, but that is not documented. [ERROR] Failures: [ERROR] HttpCoreApiIT.parseWriteTest:82 expected: \<Keep-Alive> but was: \<Keep> Part 2: Does the DefaultHttpRequestParser handle well this raw request (HTTP Proxy tunnel): ```java String rawGet = "CONNECT example.com:80 HTTP/1.1\r\n" + "Host: example.com:80\r\n" + "Proxy-Authorization: basic aGVsbG86d29ybGQ=\r\n" + "\r\n"; ``` the request.getAuthority() return null, but expected: new URIAuthority("example.com", 80); --- **Affects:** 5.0.1 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
