RejectedSoftware Forums

Sign up

HTTPRequest with proxy

I'm trying to use proxies for http requests with the vibe.d library like this:

HTTPClientSettings settings = new HTTPClientSettings;
settings.proxyURL = URL.parse("http://gb.smartproxy.com:30000");
auto response = requestHTTP("https://dlang.org", (scope req) {
    req.method = HTTPMethod.GET;
}, settings).bodyReader.readAllUTF8;

writeln(response);

As soon as I enable the proxy settings I get errors like this on pretty much every site I try with:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://dlang.org/">here</a>.</p>
</body></html>
It works fine when I do it in python with the requests library with the same proxies

Re: HTTPRequest with proxy

#!/usr/bin/env dub
/+ dub.sdl:
	name "test"
	dependency "vibe-d" version="~>0.8.5"
+/

import std.stdio;
import vibe.d;

void main() {
   HTTPClientSettings settings = new HTTPClientSettings;
   settings.proxyURL = URL.parse("http://gb.smartproxy.com:30000");
   auto response = requestHTTP("https://dlang.org", (scope req) {
       req.method = HTTPMethod.GET;
   }, settings).bodyReader.readAllUTF8;

   writeln(response);
}

gives: vibe.http.common.HTTPStatusException@/home/tobias/.dub/packages/vibe-d-0.8.5/vibe-d/http/vibe/http/client.d(416): Proxy Authentication Required.

Sorry, can't dig any deeper.