I believe this is a bug of Poco 1.4.2
below is is the testing code.
If not using proxy, the below code can works; but if session proxy is enabled, the HTTP GET header will like below:
- Code: Select all
GET http://www.example.com:80http://www.example.com/query?r=xxx HTTP/1.1
To fix this problem, I think the HTTPClientSession.cpp code should be changed from:
- Code: Select all
212 if (!_proxyHost.empty())
213 {
214 request.setURI(proxyRequestPrefix() + [color=#BFBF00]request.getURI()[/color]);
215 proxyAuthenticate(request);
216 }
to
- Code: Select all
212 if (!_proxyHost.empty())
213 {
214 request.setURI(proxyRequestPrefix() + [b]Poco:URI(request.getURI()).getPathEtc()[/b]);
215 proxyAuthenticate(request);
216 }
other HTTPRequest URI must be set with only the PathEtc part.(ie. no scheme,host,port)
I may not access this forum for long time, if you have different option, also post to my mail box (xrg_soft(at)163.com) is appreciated!
Testing code:
- Code: Select all
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/URI.h>
#include <string>
int main(void)
{
// no error handling ...
std::string strURI = "http://www.example.com/query?r=xxx";
Poco::URI uri(strURI);
Poco::Net::HTTPClientSession session;
session.setHost(uri.getHost());
session.setPort(uri.getPort());
// Porxy switch:
// session.setProxy(<proxyHost>, <proxyPort>);
Poco::Net::HTTPRequest req("HTTP/1.1");
req.setURI(strURI); // in case of this URI is full, the bug may occurs.
session.sendRequest(req);
return 0;
}





