|
16 | 16 |
|
17 | 17 | use std::collections::BTreeMap; |
18 | 18 |
|
| 19 | +use regex; |
19 | 20 | use stacks_common::codec::{Error as CodecError, StacksMessageCodec}; |
20 | 21 | use stacks_common::types::net::{PeerAddress, PeerHost}; |
21 | 22 |
|
@@ -146,7 +147,7 @@ fn test_parse_http_request_preamble_ok() { |
146 | 147 | ("POST asdf HTTP/1.1\r\nHost: core.blockstack.org\r\nConnection: close\r\nFoo: Bar\r\n\r\n", |
147 | 148 | HttpRequestPreamble::from_headers(HttpVersion::Http11, "POST".to_string(), "asdf".to_string(), "core.blockstack.org".to_string(), 80, false, vec!["foo".to_string()], vec!["Bar".to_string()])), |
148 | 149 | ("POST asdf HTTP/1.1\r\nHost: core.blockstack.org\r\nFoo: Bar\r\nConnection: close\r\n\r\n", |
149 | | - HttpRequestPreamble::from_headers(HttpVersion::Http11, "POST".to_string(), "asdf".to_string(), "core.blockstack.org".to_string(), 80, false, vec!["foo".to_string()], vec!["Bar".to_string()])) |
| 150 | + HttpRequestPreamble::from_headers(HttpVersion::Http11, "POST".to_string(), "asdf".to_string(), "core.blockstack.org".to_string(), 80, false, vec!["foo".to_string()], vec!["Bar".to_string()])) |
150 | 151 | ]; |
151 | 152 |
|
152 | 153 | for (data, request) in tests.iter() { |
@@ -391,6 +392,14 @@ fn test_http_response_preamble_headers() { |
391 | 392 | "Content-Type is missing" |
392 | 393 | ); |
393 | 394 | assert!(txt.find("Date: ").is_some(), "Date header is missing"); |
| 395 | + |
| 396 | + let rfc7231_date_regex = |
| 397 | + regex::Regex::new(r"Date: [A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT\r\n") |
| 398 | + .unwrap(); |
| 399 | + assert!( |
| 400 | + rfc7231_date_regex.is_match(&txt), |
| 401 | + "Date header format is incorrect" |
| 402 | + ); |
394 | 403 | assert!(txt.find("foo: bar\r\n").is_some(), "foo header is missing"); |
395 | 404 | assert!( |
396 | 405 | txt.find("Access-Control-Allow-Origin: *\r\n").is_some(), |
|
0 commit comments