Skip to content

Commit 56419a1

Browse files
author
Krzysztof
committed
Retrieval of underlaying connection from http_request
1 parent a7d5e0f commit 56419a1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/http_request.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ unsigned short http_request::get_requestor_port() const
295295
return http::get_port(conninfo->client_addr);
296296
}
297297

298+
connection_info *http_request::get_connection_info() const
299+
{
300+
const MHD_ConnectionInfo *conninfo = MHD_get_connection_info(
301+
underlying_connection,
302+
MHD_CONNECTION_INFO_SOCKET_CONTEXT
303+
);
304+
305+
return static_cast<connection_info*>(conninfo->socket_context);
306+
}
307+
298308
std::ostream &operator<< (std::ostream &os, const http_request &r)
299309
{
300310
os << r.get_method() << " Request [user:\"" << r.get_user() << "\" pass:\"" << r.get_pass() << "\"] path:\""

src/httpserver/http_request.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace httpserver
3737
{
3838

3939
class webserver;
40+
class connection_info;
4041

4142
namespace http
4243
{
@@ -209,6 +210,18 @@ class http_request
209210
int nonce_timeout, bool& reload_nonce
210211
) const;
211212

213+
214+
/**
215+
* Returns the underlying MHD connection.
216+
* @return pointer to connection instance
217+
*/
218+
MHD_Connection *get_underlying_connection() const
219+
{
220+
return underlying_connection;
221+
}
222+
223+
connection_info *get_connection_info() const;
224+
212225
friend std::ostream &operator<< (std::ostream &os, http_request &r);
213226

214227
private:

0 commit comments

Comments
 (0)