Http/fix gcc 8 build (#275)
* throw exception on Read from wire Error instead of returning -1
This commit is contained in:
parent
a1ec5119a6
commit
59d7ebabe1
@ -265,12 +265,12 @@ namespace Azure { namespace Core { namespace Http {
|
||||
*/
|
||||
struct CouldNotResolveHostException : public std::exception
|
||||
{
|
||||
const char* what() const throw() { return "couldnt resolve host"; }
|
||||
const char* what() const throw() { return "could not resolve host"; }
|
||||
};
|
||||
|
||||
struct ErrorWhileWrittingResponse : public std::exception
|
||||
{
|
||||
const char* what() const throw() { return "couldnt write response"; }
|
||||
const char* what() const throw() { return "could not write response"; }
|
||||
};
|
||||
|
||||
// Any other excpetion from transport layer without an specific exception defined above
|
||||
|
||||
@ -19,13 +19,16 @@ std::unique_ptr<Response> CurlTransport::Send(Context& context, Request& request
|
||||
{
|
||||
switch (performing)
|
||||
{
|
||||
case CURLE_COULDNT_RESOLVE_HOST: {
|
||||
case CURLE_COULDNT_RESOLVE_HOST:
|
||||
{
|
||||
throw Azure::Core::Http::CouldNotResolveHostException();
|
||||
}
|
||||
case CURLE_WRITE_ERROR: {
|
||||
case CURLE_WRITE_ERROR:
|
||||
{
|
||||
throw Azure::Core::Http::ErrorWhileWrittingResponse();
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
throw Azure::Core::Http::TransportException();
|
||||
}
|
||||
}
|
||||
@ -155,8 +158,8 @@ static std::unique_ptr<Response> CreateHTTPResponse(
|
||||
static std::unique_ptr<Response> CreateHTTPResponse(std::string const& header)
|
||||
{
|
||||
return CreateHTTPResponse(
|
||||
reinterpret_cast<const uint8_t* const>(header.data()),
|
||||
reinterpret_cast<const uint8_t* const>(header.data() + header.size()));
|
||||
reinterpret_cast<const uint8_t*>(header.data()),
|
||||
reinterpret_cast<const uint8_t*>(header.data() + header.size()));
|
||||
}
|
||||
|
||||
// To wait for a socket to be ready to be read/write
|
||||
@ -479,7 +482,7 @@ int64_t CurlSession::ReadSocketToBuffer(uint8_t* buffer, int64_t bufferSize)
|
||||
break;
|
||||
default:
|
||||
// Error code while reading from socket
|
||||
return -1;
|
||||
throw Azure::Core::Http::TransportException();
|
||||
}
|
||||
}
|
||||
return readBytes;
|
||||
|
||||
@ -47,8 +47,8 @@ void Response::AddHeader(uint8_t const* const begin, uint8_t const* const last)
|
||||
void Response::AddHeader(std::string const& header)
|
||||
{
|
||||
return AddHeader(
|
||||
reinterpret_cast<uint8_t const* const>(header.data()),
|
||||
reinterpret_cast<uint8_t const* const>(header.data() + header.size()));
|
||||
reinterpret_cast<uint8_t const*>(header.data()),
|
||||
reinterpret_cast<uint8_t const*>(header.data() + header.size()));
|
||||
}
|
||||
|
||||
void Response::AddHeader(std::string const& name, std::string const& value)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user