| 83 return cx_strsubs_m(uri, i); |
83 return cx_strsubs_m(uri, i); |
| 84 } |
84 } |
| 85 } |
85 } |
| 86 |
86 |
| 87 return (cxmutstr){ "/", 1 }; |
87 return (cxmutstr){ "/", 1 }; |
| 88 } |
|
| 89 |
|
| 90 NSAPISession* nsapisession_create(pool_handle_t *pool) { |
|
| 91 NSAPISession *sn = pool_malloc(pool, sizeof(NSAPISession)); |
|
| 92 if(!sn) { |
|
| 93 return NULL; |
|
| 94 } |
|
| 95 |
|
| 96 ZERO(sn, sizeof(NSAPISession)); |
|
| 97 |
|
| 98 sn->sn.pool = pool; |
|
| 99 |
|
| 100 sn->sn.client = pblock_create_pool(sn->sn.pool, 8); |
|
| 101 if(!sn->sn.client) { |
|
| 102 pool_free(pool, sn); |
|
| 103 return NULL; |
|
| 104 } |
|
| 105 sn->sn.fill = 1; |
|
| 106 |
|
| 107 return sn; |
|
| 108 } |
|
| 109 |
|
| 110 int nsapisession_setconnection(NSAPISession *sn, Connection *conn, netbuf *inbuf, IOStream **io) { |
|
| 111 SessionHandler *sh = conn->session_handler; |
|
| 112 WSBool ssl; |
|
| 113 IOStream *sio = sh->create_iostream(sh, conn, sn->sn.pool, &ssl); |
|
| 114 if(!sio) { |
|
| 115 return 1; |
|
| 116 } |
|
| 117 *io = sio; |
|
| 118 IOStream *http = httpstream_new(sn->sn.pool, sio); |
|
| 119 if(!http) { |
|
| 120 return 1; |
|
| 121 } |
|
| 122 sn->connection = conn; |
|
| 123 sn->netbuf = inbuf; |
|
| 124 sn->sn.csd = http; |
|
| 125 sn->sn.ssl = ssl; |
|
| 126 sn->sn.inbuf = inbuf; |
|
| 127 sn->sn.inbuf->sd = http; |
|
| 128 return 0; |
|
| 129 } |
88 } |
| 130 |
89 |
| 131 int handle_request(HTTPRequest *request, threadpool_t *thrpool, EventHandler *ev) { |
90 int handle_request(HTTPRequest *request, threadpool_t *thrpool, EventHandler *ev) { |
| 132 // handle nsapi request |
91 // handle nsapi request |
| 133 |
92 |