Crates.io | http-scrap |
lib.rs | http-scrap |
version | 0.1.1129 |
source | src |
created_at | 2024-10-06 10:47:35.471864 |
updated_at | 2024-11-15 05:26:34.932317 |
description | HTTP parsing methods made easier to use |
homepage | https://crates.io/crates/http-scrap |
repository | https://github.com/HashiramaSenjuhari/http-scrap |
max_upload_size | |
id | 1398997 |
size | 9,258 |
A brief description of your crate, explaining what it does and its main features.
To include this crate in your project, add the following line to your Cargo.toml
:
[dependencies]
http-scrape = "0.1.1127"
use http_parser::Response;
fn main() {
let response = Response::new("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nHello World");
// Parse the HTTP method
let method = response.method();
println!("Method: {}", method); // Output: GET | POST | DELETE | PUT | OPTIONS
// Extract the path
let path = response.path();
println!("Path: {}", path); // Output: The requested URL path
// Get cookies (if any)
let cookie = response.cookie();
println!("Cookie: {:?}", cookie); // Output: Cookies if available
// Retrieve content from the HTTP body
let content = response.content();
println!("Content: {}", content); // Output: HTTP body content
}