Error 500 Failed to upload file using Delphi Indy -


i'm trying upload file oboom.com logged in when try post file error

http/1.1500 internal server error.

with respose text

[500,"illegal post header","content-transfer-encoding"]

procedure tform1.button1click(sender: tobject); var   s: tstringlist;   html: string;   clhttprequest1: tclhttprequest;   ssliohandlersocketopenssl: tidssliohandlersocketopenssl;   params: tidmultipartformdatastream;   http, http2: tidhttp; begin   params := tidmultipartformdatastream.create;   s := tstringlist.create;   http2 := tidhttp.create(nil);   try     cookie := tidcookiemanager.create(nil);     ssliohandlersocketopenssl := tidssliohandlersocketopenssl.create(nil);     http2.iohandler := ssliohandlersocketopenssl;     http2.handleredirects := false;     http2.connecttimeout := 10000;     http2.readtimeout := 10000;     http2.cookiemanager := cookie;     http2.allowcookies := true;     http2.request.useragent :=       'mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/33.0.1750.154 safari/537.36';     http2.request.contenttype := 'application/x-www-form-urlencoded';     http2.request.contentencoding := 'gzip, deflate';     http2.request.accept := '*/*';     http2.request.connection := 'keep-alive';     s.values['auth'] := 'email@gmail.com';     s.values['pass'] := 'password';     s.values['app_id'] := '5hwajucdicxprlv3gjab';     s.values['app_session'] := '288196272';     html := http2.post('https://www.oboom.com/1.0/login', s);       http2.free;     s.free;   end;   token := extractbetween(html, 'session":"', '"');   try     http := tidhttp.create;     http.handleredirects := true;     http.request.connection := 'keep-alive';     http.allowcookies := true;     http.cookiemanager := cookie;     http.request.referer := 'http://upload.oboom.com';     http.request.contenttype :=       'multipart/form-data; boundary=----------gi3ef1ch2gi3gl6ae0ef1km7ef1gl6';     http.request.accept := '*/*';     http.request.acceptencoding := 'gzip,deflate';     http.connecttimeout := 20000;     http.readtimeout := 20000;     http.request.useragent :=       'mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/33.0.1750.154 safari/537.36';     params.addfile('file', 'c:\users\m\pictures\martin.jpg', );     http.post('http://upload.oboom.com/1.0/ul?token=' + token +       '&parent=1&name_policy=rename', params);       http.free;     params.free;     cookie.free;   end;   memo1.text := html; end; 

i have googled hours solution no luck :/

tried way :

 params.addfile('file', 'c:\users\m\pictures\martin.jpg','application/octet-stream');  params.addfile('file', 'c:\users\m\pictures\martin.jpg','multipart/form-data'); 

but same error

i have tried clever internet compenent , succeeded uploading file use indy ..

i use delphi x3

you need rid of these lines:

http2.request.contentencoding := 'gzip, deflate'; 

http.request.acceptencoding := 'gzip,deflate'; 

tidhttp manages values based on whether compressor property assigned , enabled. and, not sending compressed request, values should not used anyway.

also, need rid of line:

http.request.contenttype :=   'multipart/form-data; boundary=----------gi3ef1ch2gi3gl6ae0ef1km7ef1gl6'; 

post() manages value you, boundary, tidmultipartformdtastream generates dynamically.

update other place content-transfer-encoding used on individual fields of tidmultipartformdatastream. each tidformdatafield has contenttransfer property. addfile() initializes 'binary', can set blank string disable header:

params.addfile(...).contenttransfer := ''; 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -