https://github.com/watchdg/rust-http-protocol
https://github.com/watchdg/rust-http-protocol
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/watchdg/rust-http-protocol
- Owner: WatchDG
- License: mit
- Created: 2021-04-22T14:05:42.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-17T05:20:50.000Z (almost 5 years ago)
- Last Synced: 2025-02-28T06:10:31.024Z (over 1 year ago)
- Language: Rust
- Size: 47.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-protocol
## Headers
```rust
extern crate http_protocol;
use http_protocol::header::Header;
use http_protocol::Headers;
fn main() {
let mut headers = Headers::new();
headers.insert(Header::Connection, &b"close"[..]);
println!("{:?}", headers);
}
```
## Response
```rust
extern crate http_protocol;
use http_protocol::header::Header;
use http_protocol::{Body, Headers, HttpVersion, Response, StatusCode};
fn main() {
let mut headers = Headers::new();
headers.insert(Header::Connection, &b"close"[..]);
let mut response_builder = Response::builder();
response_builder
.http_version(HttpVersion::Http11)
.status_code(StatusCode::S200)
.headers(headers)
.body(Body::empty());
let response = response_builder.build().unwrap();
println!("{:?}", response);
}
```