[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KIO::http_post and malformed headers?
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2002-03-25 4:12:48
[Download RAW message or body]

Hi Chris,

On Sunday 24 March 2002 22:36, Chris Wallace wrote:
> Hi everybody,
>
> Normally I just use this list as a reference if I have any problems but
> this one I can't find any information on so I thought I would ask.  I have
> search the KDE bugs, the web (via google), newsgroups, mailing lists and I
> can not find any mention of it.  What I am trying to do is connect to a
> server and send a SOAP message using KIO::http_post.  The problem that I am
> having is that the KIO::TransferJob does not seem to send the correct HTTP
> header information to the server.  I can send the same message with a
> QSocket inserting the headers and it works fine.  So after a lot of playing
> around and trying different things I decided to write a simple server which
> will just listen on a port and send any data it receives the stdout so I
> can see what is actually getting sent.  This is when I noticed that the
> header information was incorrect.  Basically, KIO::TransferJob is ignoring
> any MetaData that I add and inserting two lines before Content-Length
> causing the server to think it is receiving an empty message.  Another
> strange thing is that if I add the MetaData Content-Type with any capital
> letters it is not included (that is not sent to the server); however, if it
> is all lower case then only the value is sent, without Content-Type: before
> it.  Any help with this is greatly appreciated.



> Below is the code that I am using to connect to the server and send the
> data.
>
> void SOAPTransport::transfer(const KURL & url, ...)
> {
>       //mData is a QByteArray with a deep copy of the information
>
>       KIO::TransferJob *job = KIO::http_post(url, mData, false);
>
>       if(!job) {
>             //For some reason it has failed, probably should never happen
> but //in case it does
>             slotCanceled(job);
>             return;
>       }
>
>       job->addMetaData("content-type", QString("text/xml"));
>       //Add the SOAP Action header
>       QString action = doc.soapAction();
>       if(action.isEmpty() || action.isNull())
>             job->addMetaData("SOAPAction:", QString("\"\""));
>       else
>             job->addMetaData("SOAPAction:", QChar('\"') + action +
> QChar('\"'));

You cannot extend the HTTP headers using meta-data information at all.  This 
something we do not support for various reasons one of which is name 
collusion.  Anyways, currently it does not allow you to extend the existing 
protocol handlers (io-slaves) so it will just be ignored.  The only you can 
fix that is by hacking kio_http to add support for your specific meta-data.

> My simple server out puts to stdout:
>
> POST /odp/hello.php HTTP/1.1
> Connection: Keep-Alive
> Pragma: no-cache
> Cache-control: no-cache
> Accept: text/*, image/jpeg, image/png, image/*, */*
> Accept-Encoding: x-gzip, gzip, identity
> Accept-Charset: iso-8859-1, utf-8, *
> Accept-Language: en_US, en
> Host: localhost:30000
>
>

I do not know why this is there since kio_http does not add extra \r\n unless

[snipped for brevity]

> As you can see after the host parameter there are two empty lines causing
> the http server (Apache) to stop processing the headers and having not
> encountered a Content-Length parameter the POST seems to be empty.  Adding
> a different number of MetaData calls seems to have no effect.  I am sure
> that I missing something but I just can't see it.
>
> I am running KDE version 2.2.1 (straight from the Mandrake 8.1
> distribution).

You might also want to update to 2.2.2 release since there were a lot of bug 
fixes in kio_http.  

Regards,
Dawit A.

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic