Core: Http

git-svn-id: svn://ultimatepp.org/upp/trunk@4754 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-04-07 08:08:55 +00:00
parent db0e8ff979
commit 2959013cda
2 changed files with 21 additions and 1 deletions

View file

@ -473,11 +473,13 @@ void HttpRequest::Start()
void HttpRequest::Dns()
{
for(int i = 0; i <= Nvl(GetTimeout(), INT_MAX); i++)
for(int i = 0; i <= Nvl(GetTimeout(), INT_MAX); i++) {
if(!addrinfo.InProgress()) {
StartRequest();
return;
}
Sleep(1);
}
}
void HttpRequest::StartRequest()
@ -569,4 +571,21 @@ String HttpRequest::Execute()
return IsSuccess() ? GetContent() : String::GetVoid();
}
String HttpRequest::GetPhaseName() const
{
static const char *m[] = {
"Start",
"Resolving host name",
"Sending request",
"Receiving header",
"Receiving content",
"Receiving chunk header",
"Receiving content chunk",
"Receiving trailer",
"Finished",
"Failed",
};
return phase >= 0 && phase <= FAILED ? m[phase] : "";
}
END_UPP_NAMESPACE

View file

@ -327,6 +327,7 @@ public:
bool Do();
int GetPhase() const { return phase; }
String GetPhaseName() const;
bool InProgress() const { return phase != FAILED && phase != FINISHED; }
bool IsFailure() const { return phase == FAILED; }
bool IsSuccess() const { return phase == FINISHED && status_code >= 200 && status_code < 300; }