summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2009-06-06 23:14:05 -0400
committerDan Winship <danw@gnome.org>2009-06-06 23:14:05 -0400
commit74e7c3b0d2201058060233ce2d99860a1c43c646 (patch)
treebea74c98d9a2ea051f68b12a722104c128ff3de8
parente636754a29691d96e89297c2d7c31d829d1de878 (diff)
downloadlibsoup-74e7c3b0d2201058060233ce2d99860a1c43c646.tar.gz
Add "Content-Length: 0" to requests with a Content-Type but no body
Some servers get annoyed if a POST/PUT declares a Content-Type but contains no body, so make sure to send a 0-length body (which is different) instead.
-rw-r--r--libsoup/soup-message-client-io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c
index ebf144c7..81599229 100644
--- a/libsoup/soup-message-client-io.c
+++ b/libsoup/soup-message-client-io.c
@@ -109,7 +109,8 @@ get_request_headers (SoupMessage *req, GString *header,
*encoding = soup_message_headers_get_encoding (req->request_headers);
if ((*encoding == SOUP_ENCODING_CONTENT_LENGTH ||
*encoding == SOUP_ENCODING_NONE) &&
- req->request_body->length > 0 &&
+ (req->request_body->length > 0 ||
+ soup_message_headers_get_one (req->request_headers, "Content-Type")) &&
!soup_message_headers_get_content_length (req->request_headers)) {
*encoding = SOUP_ENCODING_CONTENT_LENGTH;
soup_message_headers_set_content_length (req->request_headers,