{"id":21802091,"url":"https://github.com/tickbh/webparse","last_synced_at":"2025-04-13T18:41:20.571Z","repository":{"id":188189738,"uuid":"678281552","full_name":"tickbh/webparse","owner":"tickbh","description":"http1.1/http2 parse http解析库","archived":false,"fork":false,"pushed_at":"2025-03-25T02:21:48.000Z","size":589,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T02:43:36.555Z","etag":null,"topics":["http","http2","httpparser","socks5"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tickbh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-08-14T07:27:52.000Z","updated_at":"2025-03-25T02:21:53.000Z","dependencies_parsed_at":"2023-09-22T09:49:52.558Z","dependency_job_id":"d266bbe4-d52f-47ab-b696-e28652c030a0","html_url":"https://github.com/tickbh/webparse","commit_stats":null,"previous_names":["tickbh/webparse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tickbh%2Fwebparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tickbh%2Fwebparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tickbh%2Fwebparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tickbh%2Fwebparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tickbh","download_url":"https://codeload.github.com/tickbh/webparse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248764376,"owners_count":21158074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","http2","httpparser","socks5"],"created_at":"2024-11-27T11:22:45.044Z","updated_at":"2025-04-13T18:41:20.548Z","avatar_url":"https://github.com/tickbh.png","language":"Rust","readme":"# webparse\n\n一个包含http1.1及http2的解析库。极少的依赖\n\n## 使用方法\n\nhttp/1.1的解析示例\n\n```rust\nlet mut req = webparse::Request::new();\nlet ret = req.parse(b\"GET /index.html HTTP/1.1\\r\\nHost\");\nassert!(ret.err().unwrap().is_partial());\n\nlet buf = b\"GET /index.html HTTP/1.1\\r\\nHost: example.domain\\r\\n\\r\\n\";\nlet ret = req.parse(buf).unwrap();\n\nassert!(ret == buf.len());\nassert!(req.is_complete());\n```\n\nhttp2的头解析示例，包含huffman，[rfc7541 C.4](https://httpwg.org/specs/rfc7541.html#huffman.code) \n```rust\nuse webparse::{Helper, http2::{frame::Headers, Decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE}, BinaryMut, Method, Scheme};\n\nfn parse_header() {\n    let mut decoder = Decoder::new();\n    // C.4.1\n    let buf = Helper::hex_to_vec(\"8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff\");\n    let buf_len = buf.len();\n    let mut header = Headers::empty();\n    let size = header.parse(BinaryMut::from(buf), \u0026mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();\n    assert!(size == buf_len);\n    assert!(header.method() == \u0026Some(Method::Get));\n    assert!(header.path() == \u0026Some(\"/\".to_string()));\n    assert!(header.scheme() == \u0026Some(Scheme::Http));\n    assert!(header.authority() == \u0026Some(\"www.example.com\".to_string()));\n\n    // C.4.2\n    let buf = Helper::hex_to_vec(\"8286 84be 5886 a8eb 1064 9cbf\");\n    let buf_len = buf.len();\n    let mut header = Headers::empty();\n    let size = header.parse(BinaryMut::from(buf), \u0026mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();\n    assert!(size == buf_len);\n    assert!(header.method() == \u0026Some(Method::Get));\n    assert!(header.path() == \u0026Some(\"/\".to_string()));\n    assert!(header.scheme() == \u0026Some(Scheme::Http));\n    assert!(header.authority() == \u0026Some(\"www.example.com\".to_string()));\n    assert!(header.fields()[\"cache-control\"] == \"no-cache\");\n\n    // C.4.3\n    let buf = Helper::hex_to_vec(\"8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf \");\n    let buf_len = buf.len();\n    let mut header = Headers::empty();\n    let size = header.parse(BinaryMut::from(buf), \u0026mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();\n    assert!(size == buf_len);\n    assert!(header.method() == \u0026Some(Method::Get));\n    assert!(header.path() == \u0026Some(\"/index.html\".to_string()));\n    assert!(header.scheme() == \u0026Some(Scheme::Https));\n    assert!(header.authority() == \u0026Some(\"www.example.com\".to_string()));\n    assert!(header.fields()[\"custom-key\"] == \"custom-value\");\n}\n```\n\n## License\nApache License, Version 2.0 ([LICENSE-APACHE](./LICENSE) or [https://apache.org/licenses/LICENSE-2.0](https://apache.org/licenses/LICENSE-2.0))","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftickbh%2Fwebparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftickbh%2Fwebparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftickbh%2Fwebparse/lists"}