Skip to content

Commit 0a80b64

Browse files
committed
Merge pull request cpp-netlib#210 from marcb1/0.9-devel-integration
Added support for more http status codes
2 parents 9391911 + 4bd81c3 commit 0a80b64

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

boost/network/protocol/http/impl/response.ipp

+57-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace boost { namespace network { namespace http {
3535
created = 201,
3636
accepted = 202,
3737
no_content = 204,
38+
partial_content = 206,
3839
multiple_choices = 300,
3940
moved_permanently = 301,
4041
moved_temporarily = 302,
@@ -45,10 +46,14 @@ namespace boost { namespace network { namespace http {
4546
not_found = 404,
4647
not_supported = 405,
4748
not_acceptable = 406,
49+
request_timeout = 408,
50+
precondition_failed = 412,
51+
unsatisfiable_range = 416,
4852
internal_server_error = 500,
4953
not_implemented = 501,
5054
bad_gateway = 502,
51-
service_unavailable = 503
55+
service_unavailable = 503,
56+
space_unavailable = 507
5257
} status;
5358

5459
/// The headers to be included in the reply.
@@ -196,6 +201,27 @@ namespace boost { namespace network { namespace http {
196201
"<head><title>Service Unavailable</title></head>"
197202
"<body><h1>503 Service Unavailable</h1></body>"
198203
"</html>";
204+
static const char space_unavailable[] =
205+
"<html>"
206+
"<head><title>Space Unavailable</title></head>"
207+
"<body><h1>HTTP/1.0 507 Insufficient Space to Store Resource</h1></body>"
208+
"</html>";
209+
static const char partial_content[] = "<html>"
210+
"<head><title>Partial Content</title></head>"
211+
"<body><h1>HTTP/1.1 206 Partial Content</h1></body>"
212+
"</html>";
213+
static const char request_timeout[] = "<html>"
214+
"<head><title>Request Timeout</title></head>"
215+
"<body><h1>HTTP/1.1 408 Request Timeout</h1></body>"
216+
"</html>";
217+
static const char precondition_failed[] = "<html>"
218+
"<head><title>Precondition Failed</title></head>"
219+
"<body><h1>HTTP/1.1 412 Precondition Failed</h1></body>"
220+
"</html>";
221+
static const char unsatisfiable_range[] = "<html>"
222+
"<head><title>Unsatisfiable Range</title></head>"
223+
"<body><h1>HTTP/1.1 416 Requested Range Not Satisfiable</h1></body>"
224+
"</html>";
199225

200226
switch (status)
201227
{
@@ -235,6 +261,16 @@ namespace boost { namespace network { namespace http {
235261
return bad_gateway;
236262
case basic_response<tags::http_server>::service_unavailable:
237263
return service_unavailable;
264+
case basic_response<tags::http_server>::space_unavailable:
265+
return space_unavailable;
266+
case basic_response<tags::http_server>::partial_content:
267+
return partial_content;
268+
case basic_response<tags::http_server>::request_timeout:
269+
return request_timeout;
270+
case basic_response<tags::http_server>::unsatisfiable_range:
271+
return unsatisfiable_range;
272+
case basic_response<tags::http_server>::precondition_failed:
273+
return precondition_failed;
238274
default:
239275
return internal_server_error;
240276
}
@@ -278,6 +314,16 @@ namespace boost { namespace network { namespace http {
278314
"HTTP/1.0 502 Bad Gateway\r\n";
279315
static const string_type service_unavailable =
280316
"HTTP/1.0 503 Service Unavailable\r\n";
317+
static const string_type space_unavailable =
318+
"HTTP/1.0 507 Insufficient Space to Store Resource\r\n";
319+
static const string_type partial_content =
320+
"HTTP/1.1 206 Partial Content\r\n";
321+
static const string_type request_timeout =
322+
"HTTP/1.1 408 Request Timeout\r\n";
323+
static const string_type precondition_failed =
324+
"HTTP/1.1 412 Precondition Failed\r\n";
325+
static const string_type unsatisfiable_range =
326+
"HTTP/1.1 416 Requested Range Not Satisfiable\r\n";
281327

282328
switch (status) {
283329
case basic_response<tags::http_server>::ok:
@@ -316,6 +362,16 @@ namespace boost { namespace network { namespace http {
316362
return buffer(bad_gateway);
317363
case basic_response<tags::http_server>::service_unavailable:
318364
return buffer(service_unavailable);
365+
case basic_response<tags::http_server>::space_unavailable:
366+
return buffer(space_unavailable);
367+
case basic_response<tags::http_server>::partial_content:
368+
return buffer(partial_content);
369+
case basic_response<tags::http_server>::request_timeout:
370+
return buffer(request_timeout);
371+
case basic_response<tags::http_server>::unsatisfiable_range:
372+
return buffer(unsatisfiable_range);
373+
case basic_response<tags::http_server>::precondition_failed:
374+
return buffer(precondition_failed);
319375
default:
320376
return buffer(internal_server_error);
321377
}

0 commit comments

Comments
 (0)