Changeset 3089
- Timestamp:
- Feb 5, 2010 4:03:29 PM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/include/pjlib-util/http_client.h
r3087 r3089 134 134 { 135 135 pj_str_t version; /**< HTTP version of the server */ 136 pj_ str_tstatus_code; /**< Status code of the request */136 pj_uint16_t status_code; /**< Status code of the request */ 137 137 pj_str_t reason; /**< Reason phrase */ 138 138 pj_http_headers headers; /**< Response headers */ -
pjproject/trunk/pjlib-util/src/pjlib-util-test/http_client.c
r3087 r3089 134 134 PJ_UNUSED_ARG(data); 135 135 136 PJ_LOG(5, (THIS_FILE, "\nData received: %d bytes \n", size));136 PJ_LOG(5, (THIS_FILE, "\nData received: %d bytes", size)); 137 137 if (size > 0) { 138 138 #ifdef VERBOSE … … 161 161 *size = sendsz; 162 162 163 PJ_LOG(5, (THIS_FILE, "\nSending data progress: %d out of %d bytes \n",163 PJ_LOG(5, (THIS_FILE, "\nSending data progress: %d out of %d bytes", 164 164 send_size, total_size)); 165 165 } … … 172 172 173 173 if (status == PJ_ECANCELLED) { 174 PJ_LOG(5, (THIS_FILE, "Request cancelled \n"));174 PJ_LOG(5, (THIS_FILE, "Request cancelled")); 175 175 return; 176 176 } else if (status == PJ_ETIMEDOUT) { 177 PJ_LOG(5, (THIS_FILE, "Request timed out! \n"));177 PJ_LOG(5, (THIS_FILE, "Request timed out!")); 178 178 return; 179 } else if (status != PJ_SUCCESS && status != PJ_EPENDING) {180 PJ_LOG(3, (THIS_FILE, "Error %d \n", status));179 } else if (status != PJ_SUCCESS) { 180 PJ_LOG(3, (THIS_FILE, "Error %d", status)); 181 181 return; 182 182 } 183 PJ_LOG(5, (THIS_FILE, "\nData completed: %d bytes \n", resp->size));183 PJ_LOG(5, (THIS_FILE, "\nData completed: %d bytes", resp->size)); 184 184 if (resp->size > 0 && resp->data) { 185 185 #ifdef VERBOSE … … 198 198 199 199 #ifdef VERBOSE 200 printf("%.*s, % .*s, %.*s\n", STR_PREC(resp->version),201 STR_PREC(resp->status_code), STR_PREC(resp->reason));200 printf("%.*s, %d, %.*s\n", STR_PREC(resp->version), 201 resp->status_code, STR_PREC(resp->reason)); 202 202 for (i = 0; i < resp->headers.count; i++) { 203 203 printf("%.*s : %.*s\n", -
pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
r3087 r3089 218 218 219 219 hreq->tcp_state.current_send_size += sent; 220 TRACE_((THIS_FILE, "\nData sent: %d out of %d bytes \n",220 TRACE_((THIS_FILE, "\nData sent: %d out of %d bytes", 221 221 hreq->tcp_state.current_send_size, hreq->tcp_state.send_size)); 222 222 if (hreq->tcp_state.current_send_size == hreq->tcp_state.send_size) { … … 280 280 pj_http_req *hreq = (pj_http_req*) pj_activesock_get_user_data(asock); 281 281 282 TRACE_((THIS_FILE, "\nData received: %d bytes \n", size));282 TRACE_((THIS_FILE, "\nData received: %d bytes", size)); 283 283 284 284 if (hreq->state == ABORTING) … … 472 472 void *newdata; 473 473 pj_scanner scanner; 474 pj_str_t s; 474 475 pj_status_t status; 475 476 … … 509 510 pj_scan_get_until_ch(&scanner, ' ', &response->version); 510 511 pj_scan_advance_n(&scanner, 1, PJ_FALSE); 511 pj_scan_get_until_ch(&scanner, ' ', &response->status_code); 512 pj_scan_get_until_ch(&scanner, ' ', &s); 513 response->status_code = (pj_uint16_t)pj_strtoul(&s); 512 514 pj_scan_advance_n(&scanner, 1, PJ_FALSE); 513 515 pj_scan_get_until_ch(&scanner, '\n', &response->reason); … … 909 911 pj_strcat2(&pkt, "\n"); 910 912 pkt.ptr[pkt.slen] = 0; 911 TRACE_((THIS_FILE, "%s \n", pkt.ptr));913 TRACE_((THIS_FILE, "%s", pkt.ptr)); 912 914 } else { 913 915 pkt.ptr = hreq->param.reqdata.data; -
pjproject/trunk/pjsip-apps/src/samples/httpdemo.c
r3087 r3089 44 44 #define THIS_FILE "http_demo" 45 45 46 static void on_response(pj_http_req *http_req, const pj_http_resp *resp) 47 { 48 PJ_LOG(3,(THIS_FILE, "%.*s %d %.*s", (int)resp->version.slen, resp->version.ptr, 49 resp->status_code, 50 (int)resp->reason.slen, resp->reason.ptr)); 51 } 52 53 static void on_send_data(pj_http_req *http_req, void **data, pj_size_t *size) 54 { 55 56 } 57 46 58 static void on_data_read(pj_http_req *hreq, void *data, pj_size_t size) 47 59 { … … 52 64 fflush(f); 53 65 #ifdef VERBOSE 54 PJ_LOG(3, (THIS_FILE, " \nData received: %d bytes\n", size));66 PJ_LOG(3, (THIS_FILE, "Data received: %d bytes", size)); 55 67 printf("%.*s\n", (int)size, (char *)data); 56 68 #endif … … 63 75 PJ_UNUSED_ARG(hreq); 64 76 65 if (status == PJ_ECANCELLED) { 66 PJ_LOG(3, (THIS_FILE, "Request cancelled\n")); 67 return; 68 } else if (status == PJ_ETIMEDOUT) { 69 PJ_LOG(3, (THIS_FILE, "Request timed out!\n")); 70 return; 71 } else if (status != PJ_SUCCESS && status != PJ_EPENDING) { 72 PJ_LOG(3, (THIS_FILE, "Error %d\n", status)); 77 if (status != PJ_SUCCESS) { 78 PJ_PERROR(1, (THIS_FILE, status, "HTTP request completed with error")); 73 79 return; 74 80 } 75 PJ_LOG(3, (THIS_FILE, " \nData completed: %d bytes\n", resp->size));81 PJ_LOG(3, (THIS_FILE, "Data completed: %d bytes", resp->size)); 76 82 if (resp->size > 0 && resp->data) { 77 83 #ifdef VERBOSE … … 90 96 hcb.on_complete = &on_complete; 91 97 hcb.on_data_read = &on_data_read; 98 hcb.on_send_data = &on_send_data; 99 hcb.on_response = &on_response; 92 100 93 101 /* Create pool, timer, and ioqueue */ … … 128 136 pj_status_t status; 129 137 130 if (argc !=3) {131 puts("Usage: httpdemo URL filename");138 if (argc < 2 || argc > 3) { 139 puts("Usage: httpdemo URL [output-filename]"); 132 140 return 1; 133 141 } 134 142 135 pj_log_set_level( 3);143 pj_log_set_level(5); 136 144 137 145 pj_init(); … … 140 148 pjlib_util_init(); 141 149 142 f = fopen(argv[2], "wb"); 150 if (argc > 2) 151 f = fopen(argv[2], "wb"); 152 else 153 f = stdout; 154 143 155 status = getURL(argv[1]); 144 156 if (status != PJ_SUCCESS) { 145 157 PJ_PERROR(1, (THIS_FILE, status, "Error")); 146 158 } 147 fclose(f);148 159 160 if (f != stdout) 161 fclose(f); 162 163 pj_caching_pool_destroy(&cp); 149 164 pj_shutdown(); 150 165 return 0;
Note: See TracChangeset
for help on using the changeset viewer.