After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686766 - "Content-Length: 0" due to empty "Content-Type"
"Content-Length: 0" due to empty "Content-Type"
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: API
unspecified
Other All
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2012-10-24 07:50 UTC by DongHyun, Song
Modified: 2013-11-17 14:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description DongHyun, Song 2012-10-24 07:50:04 UTC
Hello, I'm webkit developer in South Korea.

In case, Content-Type has "" which value is empty string, not NULL.
libsoup set "Content-Length: 0" forcely.

I think that below change is proper to handle Content-Type.

soup-message.c (any version is same)
void
soup_message_set_request (SoupMessage    *msg,
			  const char     *content_type,
			  SoupMemoryUse   req_use,
			  const char     *req_body,
			  gsize           req_length)
{
	g_return_if_fail (SOUP_IS_MESSAGE (msg));
	g_return_if_fail (content_type != NULL || req_length == 0);

--	if (content_type) {
++	if (content_type && *content_type != 0) {
		soup_message_headers_replace (msg->request_headers,
					      "Content-Type", content_type);
		soup_message_body_append (msg->request_body, req_use,
					  req_body, req_length);
	} else {
		soup_message_headers_remove (msg->request_headers,
					     "Content-Type");
		soup_message_body_truncate (msg->request_body);
	}
}

On libsoup port of webkit, this problem is reproduced when <object> include a server flash resource with parameter.

GET /static_v8/flash/playerlist-nct_121010.swf HTTP/1.1
Host: stc.nct.nixcdn.com
User-Agent: Mozilla/5.0 (SMART-TV; X11; Linux i686) AppleWebKit/534.7 (KHTML, like Gecko) Version/5.0 Safari/534.7
Content-Type: <----- mime-type is not defined from HTML content
Accept: */*
Accept-Encoding: gzip
Content-Length: 0 <---- Content-Length is set forcely
Comment 1 Dan Winship 2012-12-12 10:00:18 UTC
Have you checked that making this change doesn't break any WebKit LayoutTests? I know there a various other subtleties involving exactly when Content-Type and Content-Length are set...

If it doesn't break anything else, I'm OK with making this change.
Comment 2 Tobias Mueller 2013-06-13 07:19:42 UTC
DongHyun, Song, ping
Comment 3 DongHyun, Song 2013-06-13 07:30:34 UTC
I'm sorry, I forgot this issue.
There are no break to test WebKit RenderTests. We already did render test with modifited libsoup. Its result is OK.
(I'm in Samusng VD division, developing SmartTV Browser)
Comment 4 DongHyun, Song 2013-06-13 07:31:11 UTC
I'm sorry, I forgot this issue.
There are no break to test WebKit RenderTests. We already did render test with modifited libsoup. Its result is OK.
(I'm in Samusung VD division, developing SmartTV Browser)
Comment 5 Dan Winship 2013-08-25 13:59:08 UTC
Hm... where is soup_message_set_request() being called from? I don't see any calls to it in the WebKit source tree.

I'm thinking now that, if anything, soup_message_set_request() should g_return_if_fail() in this case; setting Content-Type to "" is just wrong, and if there is some code within WebKit that is trying to do this, then WebKit should fix it itself (ie, check if the content type is "", and change it to NULL if so).
Comment 6 Dan Winship 2013-11-17 14:24:46 UTC
I've pushed a patch to master that makes soup_message_set_request()
warn if it passed an invalid content_type. You should be checking that
before calling the function.