From 92e6ac9287f7acedec96bcf5314cbda0ef59ea23 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 27 Feb 2014 09:53:40 -0500 Subject: [PATCH] C max_chunk_size client side done Signed-off-by: Bill Erickson --- src/libopensrf/osrf_app_session.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/libopensrf/osrf_app_session.c b/src/libopensrf/osrf_app_session.c index 7ca1ab2..c7b80d3 100644 --- a/src/libopensrf/osrf_app_session.c +++ b/src/libopensrf/osrf_app_session.c @@ -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); -- 2.11.0