How to POST data with net.curl

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 2 00:45:15 PDT 2015


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.


More information about the Digitalmars-d-learn mailing list