Core: HttpRequest: WhenContent now only receives data of final OK content (not redirection or authorization texts or errors)

git-svn-id: svn://ultimatepp.org/upp/trunk@11249 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-07-16 17:40:24 +00:00
parent 718348298f
commit 5148266e5f
3 changed files with 27 additions and 16 deletions

View file

@ -57,7 +57,7 @@ void HttpRequest::Init()
redirect_count = 0;
retry_count = 0;
gzip = false;
WhenContent = callback(this, &HttpRequest::ContentOut);
all_content = false;
WhenAuthenticate = callback(this, &HttpRequest::ResolveDigestAuthentication);
chunk = 4096;
timeout = 120000;
@ -760,11 +760,6 @@ void HttpRequest::StartBody()
}
}
void HttpRequest::ContentOut(const void *ptr, int size)
{
body.Cat((const char *)ptr, size);
}
void HttpRequest::Out(const void *ptr, int size)
{
LLOG("HTTP Out " << size);
@ -775,7 +770,10 @@ void HttpRequest::Out(const void *ptr, int size)
phase = FAILED;
return;
}
WhenContent(ptr, size);
if(WhenContent && (status_code >= 200 && status_code < 300 || all_content))
WhenContent(ptr, size);
else
body.Cat((const char *)ptr, size);
}