-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b0bbf9
commit d9b2f0d
Showing
9 changed files
with
215 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...http_client_netty/src/main/kotlin/com/hexagonkt/http/client/netty/Http2SettingsHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.hexagonkt.http.client.netty | ||
|
||
import io.netty.channel.ChannelHandlerContext | ||
import io.netty.channel.ChannelPromise | ||
import io.netty.channel.SimpleChannelInboundHandler | ||
import io.netty.handler.codec.http2.Http2Settings | ||
import java.util.concurrent.TimeUnit | ||
|
||
internal class Http2SettingsHandler(private val promise: ChannelPromise) : | ||
SimpleChannelInboundHandler<Http2Settings>() { | ||
fun awaitSettings(timeout: Long, unit: TimeUnit?) { | ||
check(promise.awaitUninterruptibly(timeout, unit)) { "Timed out waiting for settings" } | ||
} | ||
|
||
override fun channelRead0(ctx: ChannelHandlerContext, msg: Http2Settings) { | ||
promise.setSuccess() | ||
|
||
ctx.pipeline().remove(this) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...client_netty/src/main/kotlin/com/hexagonkt/http/client/netty/HttpClientResponseHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.hexagonkt.http.client.netty | ||
|
||
import io.netty.channel.ChannelHandlerContext | ||
import io.netty.channel.SimpleChannelInboundHandler | ||
import io.netty.handler.codec.http.FullHttpResponse | ||
import io.netty.handler.codec.http.HttpUtil | ||
import io.netty.handler.codec.http.LastHttpContent | ||
import io.netty.util.CharsetUtil | ||
|
||
class HttpClientResponseHandler : SimpleChannelInboundHandler<FullHttpResponse>() { | ||
|
||
lateinit var response: FullHttpResponse | ||
override fun channelRead0(ctx: ChannelHandlerContext, msg: FullHttpResponse) { | ||
System.err.println("STATUS: " + msg.status()) | ||
System.err.println("VERSION: " + msg.protocolVersion()) | ||
System.err.println() | ||
response = msg | ||
|
||
if (!msg.headers().isEmpty) { | ||
for (name in msg.headers().names()) { | ||
for (value in msg.headers().getAll(name)) { | ||
System.err.println("HEADER: $name = $value") | ||
} | ||
} | ||
System.err.println() | ||
} | ||
|
||
if (HttpUtil.isTransferEncodingChunked(msg)) { | ||
System.err.println("CHUNKED CONTENT {") | ||
} else { | ||
System.err.println("CONTENT {") | ||
} | ||
|
||
System.err.print(msg.content().toString(CharsetUtil.UTF_8)) | ||
System.err.flush() | ||
|
||
if (msg is LastHttpContent) { | ||
System.err.println("} END OF CONTENT") | ||
ctx.close() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.