377 if(ctlen_str) { |
377 if(ctlen_str) { |
378 int64_t ctlen; |
378 int64_t ctlen; |
379 if(util_strtoint(ctlen_str, &ctlen)) { |
379 if(util_strtoint(ctlen_str, &ctlen)) { |
380 netbuf *nb = sn->netbuf; |
380 netbuf *nb = sn->netbuf; |
381 HttpStream *net_io = (HttpStream*)sn->sn.csd; |
381 HttpStream *net_io = (HttpStream*)sn->sn.csd; |
|
382 net_io->read_eof = WS_FALSE; |
382 |
383 |
383 // how many bytes are already read and in the buffer |
384 // how many bytes are already read and in the buffer |
384 int cur_input_available = nb->cursize - nb->pos; |
385 int cur_input_available = nb->cursize - nb->pos; |
385 |
386 |
386 if(cur_input_available >= ctlen) { |
387 if(cur_input_available >= ctlen) { |
564 return r; |
565 return r; |
565 } |
566 } |
566 |
567 |
567 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { |
568 int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { |
568 request_free_resources(sn, rq); |
569 request_free_resources(sn, rq); |
|
570 |
|
571 WSBool read_stream_eof = httpstream_eof(sn->sn.csd); |
|
572 if(!read_stream_eof) { |
|
573 log_ereport(LOG_WARN, "request input stream not closed"); |
|
574 // TODO: clean stream |
|
575 rq->rq.rq_attr.keep_alive = 0; // workaround |
|
576 } |
|
577 if(sn->pos < sn->cursize) { |
|
578 log_ereport(LOG_WARN, "nsapi_finish_request: TODO: remaining bytes in buffer"); |
|
579 // TODO: reuse buffer in next request |
|
580 rq->rq.rq_attr.keep_alive = 0; // workaround |
|
581 } |
569 |
582 |
570 if(rq->rq.rq_attr.keep_alive) { |
583 if(rq->rq.rq_attr.keep_alive) { |
571 SessionHandler *sh = sn->connection->session_handler; |
584 SessionHandler *sh = sn->connection->session_handler; |
572 sh->keep_alive(sh, sn->connection); |
585 sh->keep_alive(sh, sn->connection); |
573 /* |
586 /* |