mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-31 07:12:39 -06:00
First version of HttpsClient (using SSL)
git-svn-id: svn://ultimatepp.org/upp/trunk@2042 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c0dea5dff1
commit
04b10ecca1
6 changed files with 98 additions and 20 deletions
|
|
@ -246,21 +246,16 @@ String HttpClient::Execute(Gate2<int, int> progress)
|
|||
Close();
|
||||
error = Null;
|
||||
bool use_proxy = !IsNull(proxy_host);
|
||||
String sock_host = (use_proxy ? proxy_host : host);
|
||||
int sock_port = (use_proxy ? proxy_port : port);
|
||||
socket_host = (use_proxy ? proxy_host : host);
|
||||
socket_port = (use_proxy ? proxy_port : port);
|
||||
|
||||
LLOG("socket host = " << sock_host << ":" << sock_port);
|
||||
if(!socket.IsOpen()) {
|
||||
if(!ClientSocket(socket, sock_host, sock_port, true, NULL, 0, false)) {
|
||||
error = Socket::GetErrorText();
|
||||
return String::GetVoid();
|
||||
}
|
||||
socket.Linger(0);
|
||||
}
|
||||
LLOG("socket host = " << socket_host << ":" << socket_port);
|
||||
if(!socket.IsOpen() && !CreateClientSocket())
|
||||
return String::GetVoid();
|
||||
while(!socket.PeekWrite(1000)) {
|
||||
int time = msecs();
|
||||
if(time >= end_time) {
|
||||
error = NFormat(t_("%s:%d: connecting to host timed out"), sock_host, sock_port);
|
||||
error = NFormat(t_("%s:%d: connecting to host timed out"), socket_host, socket_port);
|
||||
return String::GetVoid();
|
||||
}
|
||||
if(progress(time - start_time, end_time - start_time)) {
|
||||
|
|
@ -534,6 +529,16 @@ EXIT:
|
|||
return body;
|
||||
}
|
||||
|
||||
bool HttpClient::CreateClientSocket()
|
||||
{
|
||||
if(!ClientSocket(socket, socket_host, socket_port, true, NULL, 0, false)) {
|
||||
error = Socket::GetErrorText();
|
||||
return false;
|
||||
}
|
||||
socket.Linger(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
String HttpClientGet(String url, String proxy, String username, String password,
|
||||
String *server_headers, String *error, Gate2<int, int> progress,
|
||||
int timeout, int num_redirect, int retries)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue