Poco HTTP upload file, HTTP header written in file

16 views Asked by At

When I upload a file complete, I checked the result and found HTTP header infomation has written into the file, like this: enter image description here tail is: enter image description here Left side is http server recived, right is source. My code:

Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_PUT, uri.getPathAndQuery(),
 Poco::Net::HTTPMessage::HTTP_1_1);
Poco::Net::HTMLForm form(Poco::Net::HTMLForm::ENCODING_MULTIPART);
form.addPart("file", new Poco::Net::FilePartSource(file_name,"application/octet-stream"));
        
form.prepareSubmit(req);
form.write(session.sendRequest(req));
std::istream& iss = session.receiveResponse(res);
Poco::StreamCopier::copyStream(iss, std::cout);

How to fix the problem

I want to know how to upload a binrary file use Poco::Net::HTTPClient

0

There are 0 answers