From 4bd81c31035b194756d4575c352c18e28e09a7af Mon Sep 17 00:00:00 2001 From: Marc B Date: Thu, 14 Feb 2013 11:53:44 -0500 Subject: [PATCH] Added support for more http status codes --- boost/network/protocol/http/impl/response.ipp | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/boost/network/protocol/http/impl/response.ipp b/boost/network/protocol/http/impl/response.ipp index 2eb669dba..0630bbde3 100644 --- a/boost/network/protocol/http/impl/response.ipp +++ b/boost/network/protocol/http/impl/response.ipp @@ -35,6 +35,7 @@ namespace boost { namespace network { namespace http { created = 201, accepted = 202, no_content = 204, + partial_content = 206, multiple_choices = 300, moved_permanently = 301, moved_temporarily = 302, @@ -45,10 +46,14 @@ namespace boost { namespace network { namespace http { not_found = 404, not_supported = 405, not_acceptable = 406, + request_timeout = 408, + precondition_failed = 412, + unsatisfiable_range = 416, internal_server_error = 500, not_implemented = 501, bad_gateway = 502, - service_unavailable = 503 + service_unavailable = 503, + space_unavailable = 507 } status; /// The headers to be included in the reply. @@ -196,6 +201,27 @@ namespace boost { namespace network { namespace http { "Service Unavailable" "

503 Service Unavailable

" ""; + static const char space_unavailable[] = + "" + "Space Unavailable" + "

HTTP/1.0 507 Insufficient Space to Store Resource

" + ""; + static const char partial_content[] = "" + "Partial Content" + "

HTTP/1.1 206 Partial Content

" + ""; + static const char request_timeout[] = "" + "Request Timeout" + "

HTTP/1.1 408 Request Timeout

" + ""; + static const char precondition_failed[] = "" + "Precondition Failed" + "

HTTP/1.1 412 Precondition Failed

" + ""; + static const char unsatisfiable_range[] = "" + "Unsatisfiable Range" + "

HTTP/1.1 416 Requested Range Not Satisfiable

" + ""; switch (status) { @@ -235,6 +261,16 @@ namespace boost { namespace network { namespace http { return bad_gateway; case basic_response::service_unavailable: return service_unavailable; + case basic_response::space_unavailable: + return space_unavailable; + case basic_response::partial_content: + return partial_content; + case basic_response::request_timeout: + return request_timeout; + case basic_response::unsatisfiable_range: + return unsatisfiable_range; + case basic_response::precondition_failed: + return precondition_failed; default: return internal_server_error; } @@ -278,6 +314,16 @@ namespace boost { namespace network { namespace http { "HTTP/1.0 502 Bad Gateway\r\n"; static const string_type service_unavailable = "HTTP/1.0 503 Service Unavailable\r\n"; + static const string_type space_unavailable = + "HTTP/1.0 507 Insufficient Space to Store Resource\r\n"; + static const string_type partial_content = + "HTTP/1.1 206 Partial Content\r\n"; + static const string_type request_timeout = + "HTTP/1.1 408 Request Timeout\r\n"; + static const string_type precondition_failed = + "HTTP/1.1 412 Precondition Failed\r\n"; + static const string_type unsatisfiable_range = + "HTTP/1.1 416 Requested Range Not Satisfiable\r\n"; switch (status) { case basic_response::ok: @@ -316,6 +362,16 @@ namespace boost { namespace network { namespace http { return buffer(bad_gateway); case basic_response::service_unavailable: return buffer(service_unavailable); + case basic_response::space_unavailable: + return buffer(space_unavailable); + case basic_response::partial_content: + return buffer(partial_content); + case basic_response::request_timeout: + return buffer(request_timeout); + case basic_response::unsatisfiable_range: + return buffer(unsatisfiable_range); + case basic_response::precondition_failed: + return buffer(precondition_failed); default: return buffer(internal_server_error); }