Changeset 3098 for pjproject/trunk
- Timestamp:
- Feb 11, 2010 12:50:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
r3095 r3098 185 185 pj_http_req *hreq = (pj_http_req*) pj_activesock_get_user_data(asock); 186 186 187 if (hreq->state == ABORTING )187 if (hreq->state == ABORTING || hreq->state == IDLE) 188 188 return PJ_FALSE; 189 189 … … 208 208 PJ_UNUSED_ARG(op_key); 209 209 210 if (hreq->state == ABORTING )210 if (hreq->state == ABORTING || hreq->state == IDLE) 211 211 return PJ_FALSE; 212 212 … … 282 282 TRACE_((THIS_FILE, "\nData received: %d bytes", size)); 283 283 284 if (hreq->state == ABORTING )284 if (hreq->state == ABORTING || hreq->state == IDLE) 285 285 return PJ_FALSE; 286 286 … … 326 326 hreq->response.data = NULL; 327 327 hreq->response.size = 0; 328 if (rem > 0) { 329 /* There is some response data remaining after parsing the 330 * header, move it to the front of the buffer. 331 */ 332 pj_memmove((char *)data, (char *)data + size - rem, rem); 333 *remainder = rem; 334 } 335 /* Speed up the operation a bit rather than waiting for EOF */ 336 if (hreq->response.content_length == 0) { 337 return http_on_data_read(asock, NULL, 0, PJ_SUCCESS, NULL); 338 } 339 328 329 if (rem > 0 || hreq->response.content_length == 0) 330 http_on_data_read(asock, (rem == 0 ? NULL: 331 (char *)data + size - rem), 332 rem, PJ_SUCCESS, NULL); 340 333 } 341 334 … … 343 336 } 344 337 345 pj_assert(hreq->state == READING_DATA); 338 if (hreq->state != READING_DATA) 339 return PJ_FALSE; 346 340 if (hreq->cb.on_data_read) { 347 341 /* If application wishes to receive the data once available, call … … 386 380 * or if it's already EOF. 387 381 */ 388 if ((pj_ssize_t)hreq->tcp_state.current_read_size >= 389 hreq->response.content_length || 382 if ((hreq->response.content_length >=0 && 383 (pj_ssize_t)hreq->tcp_state.current_read_size >= 384 hreq->response.content_length) || 390 385 (status == PJ_EEOF && hreq->response.content_length == -1)) 391 386 { … … 783 778 &http_req->addr, &http_req->hurl.host, 784 779 http_req->hurl.port); 785 if (status != PJ_SUCCESS || 780 if (status != PJ_SUCCESS || 786 781 !pj_sockaddr_has_addr(&http_req->addr) || 787 (http_req->param.addr_family==pj_AF_INET() && 788 http_req->addr.ipv4.sin_addr.s_addr==PJ_INADDR_NONE)) 782 (http_req->param.addr_family==pj_AF_INET() && 783 http_req->addr.ipv4.sin_addr.s_addr==PJ_INADDR_NONE)) 789 784 { 790 785 return status; // cannot resolve host name
Note: See TracChangeset
for help on using the changeset viewer.