Index: /pjproject/trunk/pjlib-util/include/pjlib-util/http_client.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/http_client.h	(revision 3088)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/http_client.h	(revision 3089)
@@ -134,5 +134,5 @@
 {
     pj_str_t        version;        /**< HTTP version of the server */
-    pj_str_t        status_code;    /**< Status code of the request */
+    pj_uint16_t     status_code;    /**< Status code of the request */
     pj_str_t        reason;         /**< Reason phrase */
     pj_http_headers headers;        /**< Response headers */
Index: /pjproject/trunk/pjlib-util/src/pjlib-util-test/http_client.c
===================================================================
--- /pjproject/trunk/pjlib-util/src/pjlib-util-test/http_client.c	(revision 3088)
+++ /pjproject/trunk/pjlib-util/src/pjlib-util-test/http_client.c	(revision 3089)
@@ -134,5 +134,5 @@
     PJ_UNUSED_ARG(data);
 
-    PJ_LOG(5, (THIS_FILE, "\nData received: %d bytes\n", size));
+    PJ_LOG(5, (THIS_FILE, "\nData received: %d bytes", size));
     if (size > 0) {
 #ifdef VERBOSE
@@ -161,5 +161,5 @@
     *size = sendsz;
 
-    PJ_LOG(5, (THIS_FILE, "\nSending data progress: %d out of %d bytes\n", 
+    PJ_LOG(5, (THIS_FILE, "\nSending data progress: %d out of %d bytes", 
            send_size, total_size));
 }
@@ -172,14 +172,14 @@
 
     if (status == PJ_ECANCELLED) {
-        PJ_LOG(5, (THIS_FILE, "Request cancelled\n"));
+        PJ_LOG(5, (THIS_FILE, "Request cancelled"));
         return;
     } else if (status == PJ_ETIMEDOUT) {
-        PJ_LOG(5, (THIS_FILE, "Request timed out!\n"));
+        PJ_LOG(5, (THIS_FILE, "Request timed out!"));
         return;
-    } else if (status != PJ_SUCCESS && status != PJ_EPENDING) {
-        PJ_LOG(3, (THIS_FILE, "Error %d\n", status));
+    } else if (status != PJ_SUCCESS) {
+        PJ_LOG(3, (THIS_FILE, "Error %d", status));
         return;
     }
-    PJ_LOG(5, (THIS_FILE, "\nData completed: %d bytes\n", resp->size));
+    PJ_LOG(5, (THIS_FILE, "\nData completed: %d bytes", resp->size));
     if (resp->size > 0 && resp->data) {
 #ifdef VERBOSE
@@ -198,6 +198,6 @@
 
 #ifdef VERBOSE
-    printf("%.*s, %.*s, %.*s\n", STR_PREC(resp->version),
-           STR_PREC(resp->status_code), STR_PREC(resp->reason));
+    printf("%.*s, %d, %.*s\n", STR_PREC(resp->version),
+           resp->status_code, STR_PREC(resp->reason));
     for (i = 0; i < resp->headers.count; i++) {
         printf("%.*s : %.*s\n", 
Index: /pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
===================================================================
--- /pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c	(revision 3088)
+++ /pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c	(revision 3089)
@@ -218,5 +218,5 @@
 
     hreq->tcp_state.current_send_size += sent;
-    TRACE_((THIS_FILE, "\nData sent: %d out of %d bytes\n", 
+    TRACE_((THIS_FILE, "\nData sent: %d out of %d bytes", 
            hreq->tcp_state.current_send_size, hreq->tcp_state.send_size));
     if (hreq->tcp_state.current_send_size == hreq->tcp_state.send_size) {
@@ -280,5 +280,5 @@
     pj_http_req *hreq = (pj_http_req*) pj_activesock_get_user_data(asock);
 
-    TRACE_((THIS_FILE, "\nData received: %d bytes\n", size));
+    TRACE_((THIS_FILE, "\nData received: %d bytes", size));
 
     if (hreq->state == ABORTING)
@@ -472,4 +472,5 @@
     void *newdata;
     pj_scanner scanner;
+    pj_str_t s;
     pj_status_t status;
 
@@ -509,5 +510,6 @@
         pj_scan_get_until_ch(&scanner, ' ', &response->version);
         pj_scan_advance_n(&scanner, 1, PJ_FALSE);
-        pj_scan_get_until_ch(&scanner, ' ', &response->status_code);
+        pj_scan_get_until_ch(&scanner, ' ', &s);
+        response->status_code = (pj_uint16_t)pj_strtoul(&s);
         pj_scan_advance_n(&scanner, 1, PJ_FALSE);
         pj_scan_get_until_ch(&scanner, '\n', &response->reason);
@@ -909,5 +911,5 @@
         pj_strcat2(&pkt, "\n");
         pkt.ptr[pkt.slen] = 0;
-        TRACE_((THIS_FILE, "%s\n", pkt.ptr));
+        TRACE_((THIS_FILE, "%s", pkt.ptr));
     } else {
         pkt.ptr = hreq->param.reqdata.data;
Index: /pjproject/trunk/pjsip-apps/src/samples/httpdemo.c
===================================================================
--- /pjproject/trunk/pjsip-apps/src/samples/httpdemo.c	(revision 3088)
+++ /pjproject/trunk/pjsip-apps/src/samples/httpdemo.c	(revision 3089)
@@ -44,4 +44,16 @@
 #define THIS_FILE	    "http_demo"
 
+static void on_response(pj_http_req *http_req, const pj_http_resp *resp)
+{
+    PJ_LOG(3,(THIS_FILE, "%.*s %d %.*s", (int)resp->version.slen, resp->version.ptr,
+				           resp->status_code,
+				           (int)resp->reason.slen, resp->reason.ptr));
+}
+
+static void on_send_data(pj_http_req *http_req, void **data, pj_size_t *size)
+{
+
+}
+
 static void on_data_read(pj_http_req *hreq, void *data, pj_size_t size)
 {
@@ -52,5 +64,5 @@
         fflush(f);
 #ifdef VERBOSE
-        PJ_LOG(3, (THIS_FILE, "\nData received: %d bytes\n", size));
+        PJ_LOG(3, (THIS_FILE, "Data received: %d bytes", size));
         printf("%.*s\n", (int)size, (char *)data);
 #endif
@@ -63,15 +75,9 @@
     PJ_UNUSED_ARG(hreq);
 
-    if (status == PJ_ECANCELLED) {
-        PJ_LOG(3, (THIS_FILE, "Request cancelled\n"));
-        return;
-    } else if (status == PJ_ETIMEDOUT) {
-        PJ_LOG(3, (THIS_FILE, "Request timed out!\n"));
-        return;
-    } else if (status != PJ_SUCCESS && status != PJ_EPENDING) {
-        PJ_LOG(3, (THIS_FILE, "Error %d\n", status));
+    if (status != PJ_SUCCESS) {
+        PJ_PERROR(1, (THIS_FILE, status, "HTTP request completed with error"));
         return;
     }
-    PJ_LOG(3, (THIS_FILE, "\nData completed: %d bytes\n", resp->size));
+    PJ_LOG(3, (THIS_FILE, "Data completed: %d bytes", resp->size));
     if (resp->size > 0 && resp->data) {
 #ifdef VERBOSE
@@ -90,4 +96,6 @@
     hcb.on_complete = &on_complete;
     hcb.on_data_read = &on_data_read;
+    hcb.on_send_data = &on_send_data;
+    hcb.on_response = &on_response;
 
     /* Create pool, timer, and ioqueue */
@@ -128,10 +136,10 @@
     pj_status_t status;
 
-    if (argc != 3) {
-	puts("Usage: httpdemo URL filename");
+    if (argc < 2 || argc > 3) {
+	puts("Usage: httpdemo URL [output-filename]");
 	return 1;
     }
 
-    pj_log_set_level(3);
+    pj_log_set_level(5);
 
     pj_init();
@@ -140,11 +148,18 @@
     pjlib_util_init();
 
-    f = fopen(argv[2], "wb");
+    if (argc > 2)
+	f = fopen(argv[2], "wb");
+    else
+	f = stdout;
+
     status = getURL(argv[1]);
     if (status != PJ_SUCCESS) {
         PJ_PERROR(1, (THIS_FILE, status, "Error"));
     }
-    fclose(f);
 
+    if (f != stdout)
+	fclose(f);
+
+    pj_caching_pool_destroy(&cp);
     pj_shutdown();
     return 0;
