|
|
Home » U++ Library support » U++ MT-multithreading and servers » HTTPREQUEST using Proxy not working -- SOLVED
HTTPREQUEST using Proxy not working -- SOLVED [message #61716] |
Sat, 28 June 2025 17:04  |
 |
deep
Messages: 272 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi
I want to connect to internet via proxy. Checked on Win11. UPP build 17953.
Code I am using. Compiled with Core and Core/SSL packages.
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN {
HttpRequest http(
"https://restcountries.com/v3.1/name/germany?fullText=true&fields=name,capital");
http.SSLProxy("http://192.168.1.1",3128);
http.SSLProxyAuth("username","password");
http.Trace(true);
auto content = http.Method(HttpRequest::METHOD_GET).Execute();
if(content.IsVoid()) {
Cout() << "Failed to execute GET request with error code " << http.GetStatusCode()
<< ".\n";
return;
}
DUMP(content);
}
With Trace on log
HTTP START
Using proxy http://192.168.1.1:3128
Starting status 2 'Resolving host name', url: restcountries.com
HTTP Execute: Resolving host name
HTTP StartConnect
HTTP retry on error connect: not found
Starting status 1 'Start', url: restcountries.com
HTTP Execute: Start
HTTP START
Using proxy http://192.168.1.1:3128
Starting status 2 'Resolving host name', url: restcountries.com
HTTP Execute: Resolving host name
HTTP StartConnect
HTTP retry on error connect: not found
Request help
Warm Regards
Deepak
[Updated on: Mon, 30 June 2025 11:42] Report message to a moderator
|
|
|
Re: HTTPREQUEST using Proxy not working [message #61717 is a reply to message #61716] |
Sat, 28 June 2025 17:30   |
Oblivion
Messages: 1214 Registered: August 2007
|
Senior Contributor |
|
|
Hello Deepak.
The SSL header is missing. You need to add it too.
I tested it with tinyproxy/localhost and it works fine:
#include <Core/Core.h>
#include <Core/SSL/SSL.h> // <==
using namespace Upp;
CONSOLE_APP_MAIN {
HttpRequest http(
"https://restcountries.com/v3.1/name/germany?fullText=true&fields=name,capital");
http.SSLProxy("localhost",8888);
http.SSLProxyAuth("username","password");
http.Trace(true);
auto content = http.Method(HttpRequest::METHOD_GET).Execute();
if(content.IsVoid()) {
Cout() << "Failed to execute GET request with error code " << http.GetStatusCode()
<< ".\n";
return;
}
DUMP(content);
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sat, 28 June 2025 17:31] Report message to a moderator
|
|
|
Re: HTTPREQUEST using Proxy not working [message #61719 is a reply to message #61717] |
Mon, 30 June 2025 07:53   |
 |
deep
Messages: 272 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi Oblivion,
Thank you for your response.
After adding
#include <Core/SSL/SSL.h> // <==
I get same error.
I am using squid proxy.
With browser set to use proxy is accessing the url with same username and password.
Any other hints.
Code Section from http.cpp
void HttpRequest::StartConnect()
{
LLOG("HTTP StartConnect");
if(!Connect(addrinfo))
return;
addrinfo.Clear();
if(ssl && ssl_proxy_host.GetCount() && !ssl_get_proxy) {
StartPhase(SSLPROXYREQUEST);
waitevents = WAIT_WRITE;
String host_port = host;
if(port)
host_port << ':' << port;
else
host_port << ":443";
data << "CONNECT " << host_port << " HTTP/1.1\r\n"
<< "Host: " << host_port << "\r\n";
if(!IsNull(ssl_proxy_username))
data << "Proxy-Authorization: Basic "
<< Base64Encode(proxy_username + ':' + proxy_password) << "\r\n";
data << "\r\n";
count = 0;
LLOG("HTTPS proxy request:\n" << data);
}
else
AfterConnect();
}
I get HTTP StartConnect in log file
I am not getting HTTPS proxy request: in log file
Warm Regards
Deepak
[Updated on: Mon, 30 June 2025 08:02] Report message to a moderator
|
|
|
Re: HTTPREQUEST using Proxy not working -- SOLVED [message #61720 is a reply to message #61719] |
Mon, 30 June 2025 11:37  |
 |
deep
Messages: 272 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
It is little strange but working
I added just to check with giving both Proxy and SSLProxy parameters. It is working only when both are assigned.
#include <Core/Core.h>
#include <Core/SSL/SSL.h>
using namespace Upp;
CONSOLE_APP_MAIN {
HttpRequest http(
"https://restcountries.com/v3.1/name/germany?fullText=true&fields=name,capital");
http.SSLProxy("http://192.168.1.1",3128);
http.SSLProxyAuth("username","password");
http.Proxy("http://192.168.1.1",3128); <<<===
http.ProxyAuth("username","password"); <<<===
http.Trace(true);
auto content = http.Method(HttpRequest::METHOD_GET).Execute();
if(content.IsVoid()) {
Cout() << "Failed to execute GET request with error code " << http.GetStatusCode()
<< ".\n";
return;
}
DUMP(content);
}
Warm Regards
Deepak
|
|
|
Goto Forum:
Current Time: Fri Jul 04 11:05:12 CEST 2025
Total time taken to generate the page: 0.03905 seconds
|
|
|