[libsoup] Fix SoupLogger to not crash with streamed requests



commit 37de8a7526abc11bcb7346884598801589b9dd61
Author: Dan Winship <danw gnome org>
Date:   Fri Aug 21 19:49:42 2009 -0400

    Fix SoupLogger to not crash with streamed requests
    
    http://bugzilla.gnome.org/show_bug.cgi?id=591857

 libsoup/soup-logger.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index b38cb87..089a505 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -67,16 +67,17 @@
  * used to identify when multiple messages are sent across the same
  * connection.
  *
- * The request half of the message is logged just before the first
- * byte of the request gets written to the network (from the
- * #SoupSession::request_started signal), and the response is logged
- * just after the last byte of the response body is read from the
- * network (from the #SoupMessage::got_body or
- * #SoupMessage::got_informational signal). In particular, note that
- * the #SoupMessage::got_headers signal, and anything triggered off it
- * (such as #SoupSession::authenticate) will be emitted
- * <emphasis>before</emphasis> the response headers are actually
- * logged.
+ * Currently, the request half of the message is logged just before
+ * the first byte of the request gets written to the network (from the
+ * #SoupSession::request_started signal), which means that if you have
+ * not made the complete request body available at that point, it will
+ * not be logged. The response is logged just after the last byte of
+ * the response body is read from the network (from the
+ * #SoupMessage::got_body or #SoupMessage::got_informational signal),
+ * which means that the #SoupMessage::got_headers signal, and anything
+ * triggered off it (such as #SoupSession::authenticate) will be
+ * emitted <emphasis>before</emphasis> the response headers are
+ * actually logged.
  **/
 
 static void soup_logger_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data);
@@ -506,10 +507,12 @@ print_request (SoupLogger *logger, SoupMessage *msg,
 	if (log_level == SOUP_LOGGER_LOG_HEADERS)
 		return;
 
-	if (msg->request_body->length) {
+	if (msg->request_body->length &&
+	    soup_message_body_get_accumulate (msg->request_body)) {
 		SoupBuffer *request;
 
 		request = soup_message_body_flatten (msg->request_body);
+		g_return_if_fail (request != NULL);
 		soup_buffer_free (request);
 
 		if (soup_message_headers_get_expectations (msg->request_headers) != SOUP_EXPECTATION_CONTINUE) {
@@ -560,7 +563,7 @@ print_response (SoupLogger *logger, SoupMessage *msg)
 	if (log_level == SOUP_LOGGER_LOG_HEADERS)
 		return;
 
-	if (msg->response_body->length) {
+	if (msg->response_body->data) {
 		soup_logger_print (logger, SOUP_LOGGER_LOG_BODY, '<',
 				   "\n%s", msg->response_body->data);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]