mirror of https://github.com/adamdruppe/arsd.git
catchup
This commit is contained in:
parent
7bcd3eca8d
commit
13f3709acb
2
http.d
2
http.d
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
I no longer work on this, use http2.d instead.
|
I no longer work on this, use http2.d instead.
|
||||||
+/
|
+/
|
||||||
module arsd.http;
|
deprecated module arsd.http;
|
||||||
|
|
||||||
import std.socket;
|
import std.socket;
|
||||||
|
|
||||||
|
|
15
http2.d
15
http2.d
|
@ -75,6 +75,20 @@ HttpRequest get(string url) {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HttpRequest post(string url, string[string] req) {
|
||||||
|
auto client = new HttpClient();
|
||||||
|
ubyte[] bdata;
|
||||||
|
foreach(k, v; req) {
|
||||||
|
if(bdata.length)
|
||||||
|
bdata ~= cast(ubyte[]) "&";
|
||||||
|
bdata ~= cast(ubyte[]) encodeComponent(k);
|
||||||
|
bdata ~= cast(ubyte[]) "=";
|
||||||
|
bdata ~= cast(ubyte[]) encodeComponent(v);
|
||||||
|
}
|
||||||
|
auto request = client.request(Uri(url), HttpVerb.POST, bdata, "application/x-www-form-urlencoded");
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
/// gets the text off a url. basic operation only.
|
/// gets the text off a url. basic operation only.
|
||||||
string getText(string url) {
|
string getText(string url) {
|
||||||
auto request = get(url);
|
auto request = get(url);
|
||||||
|
@ -1090,7 +1104,6 @@ class HttpRequest {
|
||||||
ubyte[] sendBuffer;
|
ubyte[] sendBuffer;
|
||||||
|
|
||||||
HttpResponse responseData;
|
HttpResponse responseData;
|
||||||
HttpRequestParameters parameters;
|
|
||||||
private HttpClient parentClient;
|
private HttpClient parentClient;
|
||||||
|
|
||||||
size_t bodyBytesSent;
|
size_t bodyBytesSent;
|
||||||
|
|
Loading…
Reference in New Issue