diff -r d2eb5fd97df0 -r a881dc866e23 src/server/daemon/protocol.c --- a/src/server/daemon/protocol.c Fri Oct 28 19:29:38 2016 +0200 +++ b/src/server/daemon/protocol.c Sat Oct 29 20:02:26 2016 +0200 @@ -28,13 +28,18 @@ #include "protocol.h" +#include "session.h" +#include "httplistener.h" +#include "request.h" + #include "../util/pblock.h" #include "../util/pool.h" -#include "session.h" #include "../util/io.h" #include "../util/util.h" #include "../util/strbuf.h" +#define HTTP_SCHEME "http" +#define HTTPS_SCHEME "https" void protocol_status(Session *sn, Request *rq, int n, const char *m) { rq->status_num = n; @@ -396,3 +401,30 @@ // TODO: implement return NULL; } + +void http_get_scheme_host_port( + Session *sn, + Request *rq, + char **scheme, + char **host, + uint16_t *port) +{ + Connection *con = ((NSAPISession*)sn)->connection; + + if(con->ssl) { + *scheme = HTTPS_SCHEME; + } else { + *scheme = HTTP_SCHEME; + } + + NSAPIRequest *request = (NSAPIRequest*)rq; + + if(request->host) { + *host = request->host; + } else { + *host = "localhost"; + } + + *port = request->port; + +}