static int read_body_standard(http_resp *a_resp, http_req *a_req, http_trans_conn *a_conn) { int l_rv = 0; /* anything without a content length or chunked encoding */ do { l_rv = http_trans_read_into_buf(a_conn); if (a_conn->sync == HTTP_TRANS_ASYNC) { if ((l_rv == HTTP_TRANS_NOT_DONE) || (a_conn->last_read != 0)) return HTTP_TRANS_NOT_DONE; } } while ((l_rv == HTTP_TRANS_NOT_DONE) || (a_conn->last_read > 0)); if (l_rv == HTTP_TRANS_ERR) return HTTP_TRANS_ERR; flush_response_body(a_resp, a_conn); return HTTP_TRANS_DONE; }
static int read_body_content_length(http_resp *a_resp, http_req *a_req, http_trans_conn *a_conn) { int l_len = 0; int l_left_to_read = 0; int l_rv = 0; l_len = a_resp->content_length; if (l_len == 0) return HTTP_TRANS_DONE; /* find out how much more we have to read */ l_left_to_read = l_len - a_conn->io_buf_alloc - a_resp->flushed_length - a_resp->body_len; /* set the variables */ a_conn->io_buf_io_left = l_left_to_read; a_conn->io_buf_io_done = 0; if (l_left_to_read > 0) { /* append the rest of the body to the buffer */ do { l_rv = http_trans_read_into_buf(a_conn); if ((l_rv == HTTP_TRANS_NOT_DONE) && (a_conn->sync == HTTP_TRANS_ASYNC)) return HTTP_TRANS_NOT_DONE; if ((l_rv == HTTP_TRANS_DONE) && (a_conn->last_read == 0)) return HTTP_TRANS_ERR; } while(l_rv == HTTP_TRANS_NOT_DONE); if (l_rv == HTTP_TRANS_ERR) return HTTP_TRANS_ERR; } /* write it into the body */ flush_response_body (a_resp, a_conn); return HTTP_TRANS_DONE; }
void http_resp_flush(http_resp *a_resp, http_trans_conn *a_conn) { //ghttpDebug("header_state: %d, io_buf_flush_en: %d \n", a_resp->header_state, a_conn->io_buf_flush_en); if(a_resp->header_state == http_resp_header_end && a_conn->io_buf_flush_en) flush_response_body(a_resp, a_conn); }
void http_resp_flush(http_resp *a_resp, http_trans_conn *a_conn) { flush_response_body(a_resp, a_conn); }