We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.5.9
Kotlin code (the issue isn't Kotlin-specific):
fun main() { val vertx = Vertx.vertx() val server = vertx.createHttpServer() server.requestHandler { request -> request.response().end("Hello World!") } Thread { server.listen(8123) }.start() Thread.sleep(500) // val hostPort = "nghttp2.org" to 80 val hostPort = "localhost" to 8123 val socket = Socket(hostPort.first, hostPort.second) val inp = BufferedReader(InputStreamReader(socket.getInputStream())) val out = OutputStreamWriter(socket.getOutputStream()) fun writeRequest(upgrade: Boolean) { out.write("GET / HTTP/1.1\r\n") out.write("Host: ${hostPort.first}:${hostPort.second}\r\n") if (upgrade) { out.write("Connection: Upgrade, HTTP2-Settings\r\n") out.write("Upgrade: h2c\r\n") out.write("HTTP2-Settings: AAMAAABkAAQAoAAAAAIAAAAA\r\n") } out.write("\r\n") out.flush() } fun readResponse(): String { val response = StringBuilder() var contentLength: Int? = null for (i in 1..Int.MAX_VALUE) { val line = inp.readLine()!! if (line.isEmpty()) { break } if (line.lowercase().startsWith("content-length:")) { check(contentLength == null) contentLength = line.substring("content-length:".length).trim().toInt() } if (i == 1) { response.append(line + '\n') } } if (contentLength != null) { inp.skip(contentLength.toLong()) } return response.toString() } writeRequest(upgrade = false) println(readResponse()) writeRequest(upgrade = true) println(readResponse()) }
The above code prints:
HTTP/1.1 200 OK HTTP/1.1 200 OK
While it's expected to print:
HTTP/1.1 200 OK HTTP/1.1 101 Switching Protocols
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Version
4.5.9
Steps to reproduce
Kotlin code (the issue isn't Kotlin-specific):
The above code prints:
While it's expected to print:
The text was updated successfully, but these errors were encountered: