kdevelop - sending file over http

Waldo Bastian bastian at kde.org
Wed Apr 2 11:11:51 BST 2003


On Wednesday 02 April 2003 11:52, rifat zabin wrote:
> Hello,
>
> I need help on transferring a file or large data over
> http (using kdevelop). For this there are two ways
> that I have figured out so far..
>
> 1. KHTML's multipart/form-data for form based file
> uploads.
> 2. Or KIO::http_post to POST data.
>
> But I cant find enough documentation to work on this.
> I need some sample code or document that can provide a
> clear understanding of it.
>
> And also plz let me know is there any other way of
> sending file over http?

There is also HTTP PUT. If you write the file to disk first you can use 
KIO::copy to copy it from disk to http. This will use HTTP PUT. If you don't 
want to write to disk first you can also use KIO::put. You will then need to 
connect to the dataReq() signal and provide chunks of data when you get this 
signal. An empty chunk indicates EOF. KIO::http_post works almost the same, 
but it uses HTTP POST instead of HTTP PUT.

kdelibs/khtml/khtml_part.cpp uses KIO::http_post but in a slightly different 
way. It includes all data via args.postData. This does not work for very 
large files.

You can find an example for KIO::put in kdelibs/kio/test/kioslavetest.cpp.
KIO::FileCopyJob also uses KIO::put but that has a lot of other stuff around 
it (see kdelibs/kio/kio/job.cpp)

I'm not aware of any code that uses KIO::http_post in combination with 
dataReq()

Cheers,
Waldo
-- 
bastian at kde.org -=|[ SuSE, The Linux Desktop Experts ]|=- bastian at suse.com





More information about the kfm-devel mailing list