-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff69636
commit 62c8350
Showing
17 changed files
with
6,967 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: cargo test --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "h11" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "A pure-Rust, bring-your-own-I/O implementation of HTTP/1.1" | ||
license = "Apache-2.0" | ||
license-file = "LICENSE" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
lazy_static = "1.4.0" | ||
regex = "1.10.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use lazy_static::lazy_static; | ||
|
||
pub static OWS: &str = r"[ \t]*"; | ||
pub static TOKEN: &str = r"[-!#$%&'*+.^_`|~0-9a-zA-Z]+"; | ||
pub static FIELD_NAME: &str = TOKEN; | ||
pub static VCHAR: &str = r"[\x21-\x7e]"; | ||
pub static VCHAR_OR_OBS_TEXT: &str = r"[^\x00\s]"; | ||
pub static FIELD_VCHAR: &str = VCHAR_OR_OBS_TEXT; | ||
|
||
lazy_static! { | ||
pub static ref FIELD_CONTENT: String = format!(r"{}+(?:[ \t]+{}+)*", FIELD_VCHAR, FIELD_VCHAR); | ||
pub static ref FIELD_VALUE: String = format!(r"({})?", *FIELD_CONTENT); | ||
pub static ref HEADER_FIELD: String = format!( | ||
r"(?P<field_name>{field_name}):{OWS}(?P<field_value>{field_value}){OWS}", | ||
field_name = FIELD_NAME, | ||
field_value = *FIELD_VALUE, | ||
OWS = OWS | ||
); | ||
pub static ref METHOD: String = TOKEN.to_string(); | ||
pub static ref REQUEST_TARGET: String = format!("{}+", VCHAR); | ||
pub static ref HTTP_VERSION: String = r"HTTP/(?P<http_version>[0-9]\.[0-9])".to_string(); | ||
pub static ref REQUEST_LINE: String = format!( | ||
r"(?P<method>{method}) (?P<target>{request_target}) {http_version}", | ||
method = *METHOD, | ||
request_target = *REQUEST_TARGET, | ||
http_version = *HTTP_VERSION | ||
); | ||
pub static ref STATUS_CODE: String = r"[0-9]{3}".to_string(); | ||
pub static ref REASON_PHRASE: String = format!(r"([ \t]|{})*", VCHAR_OR_OBS_TEXT); | ||
pub static ref STATUS_LINE: String = format!( | ||
r"{http_version} (?P<status_code>{status_code})(?: (?P<reason>{reason_phrase}))?", | ||
http_version = *HTTP_VERSION, | ||
status_code = *STATUS_CODE, | ||
reason_phrase = *REASON_PHRASE | ||
); | ||
pub static ref HEXDIG: String = r"[0-9A-Fa-f]".to_string(); | ||
pub static ref CHUNK_SIZE: String = format!(r"({}){{1,20}}", *HEXDIG); | ||
pub static ref CHUNK_EXT: String = ";.*".to_string(); | ||
pub static ref CHUNK_HEADER: String = format!( | ||
r"(?P<chunk_size>{chunk_size})(?P<chunk_ext>{chunk_ext})?{OWS}\r\n", | ||
chunk_size = *CHUNK_SIZE, | ||
chunk_ext = *CHUNK_EXT, | ||
OWS = OWS | ||
); | ||
} |
Oops, something went wrong.