C max_chunk_size client side done
authorBill Erickson <berick@esilibrary.com>
Thu, 27 Feb 2014 14:53:40 +0000 (09:53 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 12 Aug 2016 18:57:46 +0000 (14:57 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
src/libopensrf/osrf_app_session.c

index 7ca1ab2..c7b80d3 100644 (file)
@@ -131,11 +131,15 @@ static void _osrf_app_request_push_queue( osrfAppRequest* req, osrfMessage* resu
                req->part_response_buffer = buffer_init(OSRF_MSG_CHUNK_SIZE + 1);
         }
 
-        // add the partial contents of the message to the buffer
-        buffer_add(
-            req->part_response_buffer, 
-            jsonObjectGetString( 
-                jsonObjectGetKeyConst(result->_result_content, "content")));
+        const char* partial = jsonObjectGetString(result->_result_content);
+
+        if (partial != NULL) {
+            osrfLogDebug(OSRF_LOG_MARK, 
+                "adding %d bytes to response buffer", strlen(partial));
+        
+            // add the partial contents of the message to the buffer
+            buffer_add(req->part_response_buffer, partial);
+        }
 
         // all done.  req and result are freed by the caller
         return;
@@ -143,11 +147,18 @@ static void _osrf_app_request_push_queue( osrfAppRequest* req, osrfMessage* resu
     } else if (result->status_code == OSRF_STATUS_NOCONTENT) {
         if (req->part_response_buffer && req->part_response_buffer->n_used) {
 
-            // create a result from the completed partial message string
-            osrfLogDebug(OSRF_LOG_MARK, "received partial message complete");
+            // part_response_buffer contains a stitched-together JSON string
+            osrfLogDebug(OSRF_LOG_MARK, 
+                "partial response complete, parsing %d bytes", 
+                req->part_response_buffer->n_used);
+
+            // coerce the partial-complete response into a standard RESULT.
             osrf_message_set_status_info(result, NULL, "OK", OSRF_STATUS_OK);
+
+            // use the stitched-together JSON string as the result conten
             osrf_message_set_result_content(
                 result, req->part_response_buffer->buf);
+
             // free string, keep the buffer
             buffer_reset(req->part_response_buffer);