mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: Http now calls WhenWait when resolves DNS in blocking mode
git-svn-id: svn://ultimatepp.org/upp/trunk@4831 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
49061f09ba
commit
700ba05431
3 changed files with 26 additions and 5 deletions
|
|
@ -218,6 +218,13 @@ void HttpRequest::StartPhase(int s)
|
|||
data.Clear();
|
||||
}
|
||||
|
||||
void HttpRequest::New()
|
||||
{
|
||||
ClearError();
|
||||
ClearAbort();
|
||||
phase = BEGIN;
|
||||
}
|
||||
|
||||
bool HttpRequest::Do()
|
||||
{
|
||||
int c1, c2;
|
||||
|
|
@ -282,6 +289,7 @@ bool HttpRequest::Do()
|
|||
break;
|
||||
case FINISHED:
|
||||
case FAILED:
|
||||
WhenDo();
|
||||
return false;
|
||||
default:
|
||||
NEVER();
|
||||
|
|
@ -308,6 +316,7 @@ bool HttpRequest::Do()
|
|||
StartPhase(START);
|
||||
}
|
||||
}
|
||||
WhenDo();
|
||||
return phase != FINISHED && phase != FAILED;
|
||||
}
|
||||
|
||||
|
|
@ -326,14 +335,21 @@ void HttpRequest::Start()
|
|||
p = ssl ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT;
|
||||
String h = use_proxy ? ssl ? ssl_proxy_host : proxy_host : host;
|
||||
|
||||
StartPhase(DNS);
|
||||
if(IsNull(GetTimeout())) {
|
||||
addrinfo.Execute(h, p);
|
||||
if(WhenWait) {
|
||||
addrinfo.Start(h, p);
|
||||
while(addrinfo.InProgress()) {
|
||||
Sleep(GetWaitStep());
|
||||
WhenWait();
|
||||
}
|
||||
}
|
||||
else
|
||||
addrinfo.Execute(h, p);
|
||||
StartConnect();
|
||||
}
|
||||
else {
|
||||
else
|
||||
addrinfo.Start(h, p);
|
||||
StartPhase(DNS);
|
||||
}
|
||||
}
|
||||
|
||||
void HttpRequest::Dns()
|
||||
|
|
|
|||
|
|
@ -200,6 +200,8 @@ public:
|
|||
TcpSocket& Timeout(int ms) { timeout = ms; return *this; }
|
||||
int GetTimeout() const { return timeout; }
|
||||
TcpSocket& Blocking() { return Timeout(Null); }
|
||||
TcpSocket& WaitStep(int ms) { waitstep = ms; return *this; }
|
||||
int GetWaitStep() const { return waitstep; }
|
||||
|
||||
TcpSocket();
|
||||
~TcpSocket() { Close(); }
|
||||
|
|
@ -336,6 +338,7 @@ class HttpRequest : public TcpSocket {
|
|||
|
||||
public:
|
||||
Callback2<const void *, int> WhenContent;
|
||||
Callback WhenDo;
|
||||
|
||||
HttpRequest& MaxHeaderSize(int m) { max_header_size = m; return *this; }
|
||||
HttpRequest& MaxContentSize(int m) { max_content_size = m; return *this; }
|
||||
|
|
@ -419,6 +422,8 @@ public:
|
|||
bool IsSuccess() const { return phase == FINISHED && status_code >= 200 && status_code < 300; }
|
||||
|
||||
String Execute();
|
||||
|
||||
void New();
|
||||
|
||||
HttpRequest();
|
||||
HttpRequest(const char *url);
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ TcpSocket::TcpSocket()
|
|||
ClearError();
|
||||
Reset();
|
||||
timeout = Null;
|
||||
waitstep = 20;
|
||||
waitstep = 10;
|
||||
asn1 = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue