Skip to content

Commit 9353f91

Browse files
committed
add Host header to http request
1 parent 2a97edf commit 9353f91

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pc/rpc_client.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ rpc_client::~rpc_client()
109109
}
110110
}
111111

112-
void rpc_client::set_http_conn( net_connect *hptr )
112+
void rpc_client::set_http_conn( tcp_connect *hptr )
113113
{
114114
hptr_ = hptr;
115115
hptr_->set_net_parser( &hp_ );
116116
}
117117

118-
net_connect *rpc_client::get_http_conn() const
118+
tcp_connect *rpc_client::get_http_conn() const
119119
{
120120
return hptr_;
121121
}
@@ -170,6 +170,7 @@ void rpc_client::send( rpc_request *rptr )
170170
// submit http POST request
171171
http_request msg;
172172
msg.init( "POST", "/" );
173+
msg.add_hdr( "Host", hptr_->get_host() );
173174
msg.add_hdr( "Content-Type", "application/json" );
174175
msg.commit( jw );
175176
hptr_->add_send( msg );

pc/rpc_client.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ namespace pc
7171
~rpc_client();
7272

7373
// rpc http connection
74-
void set_http_conn( net_connect * );
75-
net_connect *get_http_conn() const;
74+
void set_http_conn( tcp_connect * );
75+
tcp_connect *get_http_conn() const;
7676

7777
// rpc web socket connection
7878
void set_ws_conn( net_connect * );
@@ -128,7 +128,7 @@ namespace pc
128128
typedef std::vector<char> acc_buf_t;
129129
typedef hash_map<trait> sub_map_t;
130130

131-
net_connect *hptr_;
131+
tcp_connect *hptr_;
132132
net_connect *wptr_;
133133
rpc_http hp_; // http parser wrapper
134134
rpc_ws wp_; // websocket parser wrapper

0 commit comments

Comments
 (0)