1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-09-01 01:16:59 +02:00

missing http codes

This commit is contained in:
Nikolay Kim
2018-01-31 12:34:58 -08:00
parent 5115384501
commit 7e9fbfca72
2 changed files with 35 additions and 5 deletions

View File

@@ -25,7 +25,7 @@ use body::Body;
use handler::Responder;
use httprequest::HttpRequest;
use httpresponse::HttpResponse;
use httpcodes::{HTTPBadRequest, HTTPMethodNotAllowed, HTTPExpectationFailed};
use httpcodes::{self, HTTPBadRequest, HTTPMethodNotAllowed, HTTPExpectationFailed};
/// A specialized [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html)
/// for actix web operations
@@ -406,7 +406,11 @@ pub enum UrlencodedError {
impl ResponseError for UrlencodedError {
fn error_response(&self) -> HttpResponse {
HttpResponse::new(StatusCode::BAD_REQUEST, Body::Empty)
match *self {
UrlencodedError::Overflow => httpcodes::HTTPPayloadTooLarge.into(),
UrlencodedError::UnknownLength => httpcodes::HTTPLengthRequired.into(),
_ => httpcodes::HTTPBadRequest.into(),
}
}
}
@@ -437,7 +441,10 @@ pub enum JsonPayloadError {
impl ResponseError for JsonPayloadError {
fn error_response(&self) -> HttpResponse {
HttpResponse::new(StatusCode::BAD_REQUEST, Body::Empty)
match *self {
JsonPayloadError::Overflow => httpcodes::HTTPPayloadTooLarge.into(),
_ => httpcodes::HTTPBadRequest.into(),
}
}
}