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

Bug#292765: kdelibs4: khtml XMLHttpRequest POST broken due to blank line in headers



Package: kdelibs4
Version: 4:3.3.2-1
Severity: normal
Tags: patch

XMLHttpRequestObject POST does not work due to an additional blank
header line printed in the HTTP headers. This due khtml's XMLHttpRequest
not setting the required content-type metadata for kio http.

See upstream bug http://bugs.kde.org/show_bug.cgi?id=95981
which has now been fixed in upstream CVS.

This would be a nice fix to get into sarge as many modern web apps
are beginning to use this functionality.

Here is a test case. Before the patch is applied you will get an
Exception alert dialog: http://oss.metaparadigm.com/jsonrpc/test.jsp

Attached is patch that was accepted upstream.

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-mc1-skas3-v7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages kdelibs4 depends on:
ii  kdelibs-bin              4:3.3.2-1       KDE core binaries
ii  kdelibs-data             4:3.3.2-1       KDE core shared data
ii  libart-2.0-2             2.3.17-1        Library of functions for 2D graphi
ii  libarts1                 1.3.2-2         aRts Sound system
ii  libasound2               1.0.8-1         ALSA library
ii  libaspell15              0.50.5-5        The GNU Aspell spell-checker runti
ii  libaudio2                1.7-2           The Network Audio System (NAS). (s
ii  libaudiofile0            0.2.6-5         Open-source version of SGI's audio
ii  libbz2-1.0               1.0.2-3         high-quality block-sorting file co
ii  libc6                    2.3.2.ds1-20    GNU C Library: Shared libraries an
ii  libcomerr2               1.36rc5-1       common error description library
ii  libcupsys2-gnutls10      1.1.23-3        Common UNIX Printing System(tm) -
ii  libesd-alsa0 [libesd0]   0.2.35-2        Enlightened Sound Daemon (ALSA) -
ii  libfam0c102              2.7.0-6         client library to control the FAM
ii  libgcc1                  1:4.0-0pre0     GCC support library
ii  libglib2.0-0             2.6.1-3         The GLib library of C routines
ii  libice6                  4.3.0.dfsg.1-10 Inter-Client Exchange library
ii  libidn11                 0.5.2-3         GNU libidn library, implementation
ii  libjack0.80.0-0          0.99.0-2        JACK Audio Connection Kit (librari
ii  libjasper-1.701-1        1.701.0-2       The JasPer JPEG-2000 runtime libra
ii  libjpeg62                6b-9            The Independent JPEG Group's JPEG
ii  libkrb53                 1.3.6-1         MIT Kerberos runtime libraries
ii  libmad0                  0.15.1b-1       MPEG audio decoder library
ii  libogg0                  1.1.0-1         Ogg Bitstream Library
ii  libopenexr2              1.2.1-3         runtime files for the OpenEXR imag
ii  libpcre3                 4.5-1.1         Perl 5 Compatible Regular Expressi
ii  libpng12-0               1.2.8rel-1      PNG library - runtime
ii  libqt3c102-mt            3:3.3.3-8       Qt GUI Library (Threaded runtime v
ii  libsm6                   4.3.0.dfsg.1-10 X Window System Session Management
ii  libstdc++5               1:3.3.5-7       The GNU Standard C++ Library v3
ii  libtiff4                 3.7.1-2         Tag Image File Format (TIFF) libra
ii  libvorbis0a              1.0.1-1         The Vorbis General Audio Compressi
ii  libvorbisenc2            1.0.1-1         The Vorbis General Audio Compressi
ii  libvorbisfile3           1.0.1-1         The Vorbis General Audio Compressi
ii  libx11-6                 4.3.0.dfsg.1-10 X Window System protocol client li
ii  libxext6                 4.3.0.dfsg.1-10 X Window System miscellaneous exte
ii  libxml2                  2.6.15-2        GNOME XML library
ii  libxrender1              0.8.3-7         X Rendering Extension client libra
ii  libxslt1.1               1.1.8-5         XSLT processing library - runtime
ii  libxt6                   4.3.0.dfsg.1-10 X Toolkit Intrinsics
ii  xbase-clients            4.3.0.dfsg.1-10 miscellaneous X clients
ii  xlibs                    4.3.0.dfsg.1-10 X Keyboard Extension (XKB) configu
ii  zlib1g                   1:1.2.2-4       compression library - runtime

-- no debconf information

--- kdelibs-3.3.2/khtml/ecma/xmlhttprequest.h	2004-11-29 01:30:52.000000000 +0800
+++ kdelibs-cvs/khtml/ecma/xmlhttprequest.h	2005-01-29 10:34:10.000000000 +0800
@@ -98,6 +98,7 @@
     QString method;
     bool async;
     QString requestHeaders;
+    QString contentType;
 
     KIO::TransferJob * job;
 
--- kdelibs-3.3.2/khtml/ecma/xmlhttprequest.cpp	2004-11-29 01:30:52.000000000 +0800
+++ kdelibs-cvs/khtml/ecma/xmlhttprequest.cpp	2005-01-29 10:08:52.000000000 +0800
@@ -110,6 +110,7 @@
 
 const ClassInfo XMLHttpRequest::info = { "XMLHttpRequest", 0, &XMLHttpRequestTable, 0 };
 
+
 /* Source for XMLHttpRequestTable.
 @begin XMLHttpRequestTable 7
   readyState		XMLHttpRequest::ReadyState		DontDelete|ReadOnly
@@ -216,6 +217,7 @@
     qObject(new XMLHttpRequestQObject(this)),
     doc(static_cast<DOM::DocumentImpl*>(d.handle())),
     async(true),
+    contentType(QString::null),
     job(0),
     state(Uninitialized),
     onReadyStateChangeListener(0),
@@ -308,6 +310,10 @@
   if (method.lower() == "post" && (url.protocol().lower() == "http" || url.protocol().lower() == "https") ) {
       // 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
   {
@@ -368,6 +374,11 @@
 
 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";
   }


Reply to: