Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Add port to Host header. It is mandatory if not the default port is u…
Browse files Browse the repository at this point in the history
…sed.
  • Loading branch information
jurmous committed Jun 16, 2015
1 parent f0827fb commit 50ca736
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void operationComplete(Future<?> future) throws Exception {

modifyPipeLine(etcdRequest, f.channel().pipeline());

createAndSendHttpRequest(uri.getHost(), etcdRequest.getUrl(), etcdRequest, channel)
createAndSendHttpRequest(uri, etcdRequest.getUrl(), etcdRequest, channel)
.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
Expand Down Expand Up @@ -267,19 +267,19 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
/**
* Get HttpRequest belonging to etcdRequest
*
* @param hostName host name for http request
* @param server server for http request
* @param uri to send request to
* @param etcdRequest to send
* @param channel to send request on
* @param <R> Response type
* @return HttpRequest
* @throws Exception when creating or sending HTTP request fails
*/
private <R> ChannelFuture createAndSendHttpRequest(String hostName, String uri, EtcdRequest<R> etcdRequest, Channel channel) throws Exception {
private <R> ChannelFuture createAndSendHttpRequest(URI server, String uri, EtcdRequest<R> etcdRequest, Channel channel) throws Exception {
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, etcdRequest.getMethod(), uri);
httpRequest.headers().add("Connection", "keep-alive");
if(this.hostName == null) {
httpRequest.headers().add("Host", hostName);
httpRequest.headers().add("Host", server.getHost() + ":" + server.getPort());
} else {
httpRequest.headers().add("Host", this.hostName);
}
Expand Down

0 comments on commit 50ca736

Please sign in to comment.