April 02, 2015 How to POST data with net.curl | ||||
---|---|---|---|---|
| ||||
I have next request, that work fine with curl: curl -X POST -F upload=@wgs84_latlon.zip http://ogre.adc4gis.com/convert I wrote next code: void main() { auto binfile = cast(ubyte[]) read(`D:\Apps\curl\wgs84_latlon.zip`); auto http = HTTP("http://ogre.adc4gis.com/convert"); http.setPostData(binfile, "-X POST -F upload=@"); http.onReceive = (ubyte[] data) { writeln((cast(string)data)); return data.length; }; http.perform(); } But I have got trouble with http.setPostData. I do not know how to properly write text part, and attaches binary zip file. |
April 03, 2015 Re: How to POST data with net.curl | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 2 April 2015 at 07:45:16 UTC, Suliman wrote: > I have next request, that work fine with curl: > curl -X POST -F upload=@wgs84_latlon.zip > http://ogre.adc4gis.com/convert > > I wrote next code: > > void main() > { > auto binfile = cast(ubyte[]) > read(`D:\Apps\curl\wgs84_latlon.zip`); > auto http = HTTP("http://ogre.adc4gis.com/convert"); > > http.setPostData(binfile, "-X POST -F upload=@"); > http.onReceive = (ubyte[] data) { writeln((cast(string)data)); > return data.length; }; > http.perform(); > } > > But I have got trouble with http.setPostData. I do not know how > to properly write text part, and attaches binary zip file. I had trouble with that too. Take a look at https://github.com/Zalastax/AvanzaFundSimulator/blob/master/source/funds/fundfetcher.d and https://github.com/Zalastax/zalastaxlibd/blob/master/source/std/extra/http.d to see if that can help. |
Copyright © 1999-2021 by the D Language Foundation