Summary: | XMLHttpRequest.setRequestHeader adds a linebreak after header | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Teofilis Martisius <teo> |
Component: | khtml ecma | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | chris+kde, opensource, zack |
Priority: | NOR | ||
Version: | 3.3.1 | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Make XMLHttpRequest set content type headers correctly for POST requests |
Description
Teofilis Martisius
2004-12-29 16:32:23 UTC
I have also found the same thing in version 3.3.2 on Gentoo. It seems that this bug does not exist in Safari 1.2.4 (but Safari does appear to append the zero byte at the end). I don't know whether that is relevent. I am not using setRequestHeader at all, and the unwanted blank line appears directly after a cookie header and before the content-length header. I've tracked this down - it is a bug in xmlHttpRequest.cpp. It doesn't set the mandatory 'content-type' metadata for the http kio_slave and kio/http/http.c just print a blank field. The Content-type does however shows up although it is set as an additional header field. This of course is the problem. Here is a test site: http://oss.metaparadigm.com/jsonrpc/test.jsp I'll follow up with a patch the fixes the problem (should apply to current CVS). The patch changes setRequestHeader to stash the Content-type instead of adding it and then it is added to the job as metadata (which is the correct method accoriding to the comments in job.h). Once you apply the patch you'll find the above test site works. Created attachment 9231 [details]
Make XMLHttpRequest set content type headers correctly for POST requests
*** This bug has been confirmed by popular vote. *** On Tuesday 25 January 2005 11:49 pm, Mathieu Jobin wrote: Voter. I'm having to use FF for this atm but i'd prefer konq. many thanks Andrew M > ------- You are receiving this mail because: ------- > You are a voter for the bug, or are watching someone who is. > > http://bugs.kde.org/show_bug.cgi?id=95981 > somekool mytradecenter com changed: > > What |Removed |Added > --------------------------------------------------------------------------- >- CC| |somekool mytradecenter com CVS commit by coolo: applying the patch as the logic seems correct to me (and Zack didn't protest) BUG: 95981 M +11 -0 xmlhttprequest.cpp 1.11 M +1 -0 xmlhttprequest.h 1.6 --- kdelibs/khtml/ecma/xmlhttprequest.cpp #1.10:1.11 @@ -217,4 +218,5 @@ XMLHttpRequest::XMLHttpRequest(ExecState doc(static_cast<DOM::DocumentImpl*>(d.handle())), async(true), + contentType(QString::null), job(0), state(Uninitialized), @@ -309,4 +311,8 @@ void XMLHttpRequest::send(const QString& // FIXME: determine post encoding correctly by looking in headers for charset job = KIO::http_post( url, QCString(_body.utf8()), false ); + if(contentType.isNull()) + job->addMetaData( "content-type", "Content-type: text/plain" ); + else + job->addMetaData( "content-type", contentType ); } else @@ -369,4 +375,9 @@ void XMLHttpRequest::abort() void XMLHttpRequest::setRequestHeader(const QString& name, const QString &value) { + // Content-type needs to be set seperately from the other headers + if(name.lower() == "content-type") { + contentType = "Content-type: " + value; + return; + } if (requestHeaders.length() > 0) { requestHeaders += "\r\n"; --- kdelibs/khtml/ecma/xmlhttprequest.h #1.5:1.6 @@ -99,4 +99,5 @@ namespace KJS { bool async; QString requestHeaders; + QString contentType; KIO::TransferJob * job; |