src/server/daemon/protocol.c

changeset 121
a881dc866e23
parent 110
43a746e905f6
child 141
ff311b63c3af
equal deleted inserted replaced
120:d2eb5fd97df0 121:a881dc866e23
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "protocol.h" 29 #include "protocol.h"
30 30
31 #include "session.h"
32 #include "httplistener.h"
33 #include "request.h"
34
31 #include "../util/pblock.h" 35 #include "../util/pblock.h"
32 #include "../util/pool.h" 36 #include "../util/pool.h"
33 #include "session.h"
34 #include "../util/io.h" 37 #include "../util/io.h"
35 #include "../util/util.h" 38 #include "../util/util.h"
36 #include "../util/strbuf.h" 39 #include "../util/strbuf.h"
37 40
41 #define HTTP_SCHEME "http"
42 #define HTTPS_SCHEME "https"
38 43
39 void protocol_status(Session *sn, Request *rq, int n, const char *m) { 44 void protocol_status(Session *sn, Request *rq, int n, const char *m) {
40 rq->status_num = n; 45 rq->status_num = n;
41 46
42 const char *msg = m ? m : protocol_status_message(n); 47 const char *msg = m ? m : protocol_status_message(n);
394 Session *sn, Request *rq) 399 Session *sn, Request *rq)
395 { 400 {
396 // TODO: implement 401 // TODO: implement
397 return NULL; 402 return NULL;
398 } 403 }
404
405 void http_get_scheme_host_port(
406 Session *sn,
407 Request *rq,
408 char **scheme,
409 char **host,
410 uint16_t *port)
411 {
412 Connection *con = ((NSAPISession*)sn)->connection;
413
414 if(con->ssl) {
415 *scheme = HTTPS_SCHEME;
416 } else {
417 *scheme = HTTP_SCHEME;
418 }
419
420 NSAPIRequest *request = (NSAPIRequest*)rq;
421
422 if(request->host) {
423 *host = request->host;
424 } else {
425 *host = "localhost";
426 }
427
428 *port = request->port;
429
430 }

mercurial