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;
} 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);