Windows/network: support status code
This commit is contained in:
parent
e6b2aeecad
commit
1ad4ef5053
@ -20,7 +20,7 @@ Request::~Request() {
|
||||
}
|
||||
|
||||
std::string sendRequest( HINTERNET hRequest, const std::wstring &headers,
|
||||
const std::string &optional ) {
|
||||
const std::string &optional, int &status_code ) {
|
||||
std::string response{};
|
||||
response.reserve( 10000 );
|
||||
|
||||
@ -64,7 +64,7 @@ std::string Request::get( const std::wstring &url ) {
|
||||
if ( !hRequest )
|
||||
std::wcerr << "ERROR HttpOpenRequest: " << GetLastError() << std::endl;
|
||||
|
||||
return sendRequest( hRequest, _headers, "" );
|
||||
return sendRequest( hRequest, _headers, "", status_code );
|
||||
}
|
||||
|
||||
std::string Request::post( const std::wstring &url, const std::string &data ) {
|
||||
@ -74,7 +74,7 @@ std::string Request::post( const std::wstring &url, const std::string &data ) {
|
||||
if ( !hRequest )
|
||||
std::wcerr << "ERROR HttpOpenRequest: " << GetLastError() << std::endl;
|
||||
|
||||
return sendRequest( hRequest, _headers, data );
|
||||
return sendRequest( hRequest, _headers, data, status_code );
|
||||
}
|
||||
|
||||
void Request::addHeader( const std::wstring &header ) {
|
||||
@ -99,7 +99,11 @@ void Request::setServer( const string &server ) {
|
||||
}
|
||||
|
||||
int Request::lastResponseCode() {
|
||||
#ifndef _WIN32
|
||||
long code{};
|
||||
curl_easy_getinfo( _curl_handle, CURLINFO_RESPONSE_CODE, &code );
|
||||
return code;
|
||||
#else
|
||||
return status_code;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user