| 113 | } |
| 114 | |
| 115 | async fn http_response_status(request: Request<Body>) -> Result<Response<Body>> { |
| 116 | let status = if let Some(header_val) = request.headers().get("x-response-status") { |
| 117 | header_val |
| 118 | .to_str() |
| 119 | .context("contents of x-response-status")? |
| 120 | .parse::<u16>() |
| 121 | .context("u16 value from x-response-status")? |
| 122 | } else { |
| 123 | 500 |
| 124 | }; |
| 125 | let mut response = Response::builder().status(status); |
| 126 | if status == 302 { |
| 127 | response = response.header("Location", "http://localhost/response-status"); |
| 128 | } |
| 129 | Ok(response.body(String::new().into())?) |
| 130 | } |
| 131 | |
| 132 | async fn http_response_fail(_request: Request<Body>) -> Result<Response<Body>> { |
| 133 | Err(anyhow::anyhow!("error creating response")) |