Expand description
§shiguredo_http11
依存なしの HTTP/1.1 スタイル テキストプロトコルライブラリ (Sans I/O)
§特徴
- 依存なし:
core/allocのみ (no_std 対応) - Sans I/O: I/O を完全に分離した設計
- 柔軟性: HTTP/1.1, RTSP/1.0, RTSP/2.0 等に対応
§使い方
§クライアント (リクエスト送信、レスポンス受信)
use shiguredo_http11::{EncodeError, Request, ResponseDecoder};
fn build() -> Result<Vec<u8>, EncodeError> {
// リクエストを作成してエンコード
let request = Request::new("GET", "/")
.unwrap()
.header("Host", "example.com")
.unwrap()
.header("Connection", "close")
.unwrap();
request.encode()
}
let bytes = build().unwrap();
// bytes を送信...
// レスポンスをデコード
let mut decoder = ResponseDecoder::new();
// 受信データを feed...
// decoder.feed(&received_data)?;
// if let Some(response) = decoder.decode()? { ... }§サーバー (リクエスト受信、レスポンス送信)
use shiguredo_http11::{EncodeError, RequestDecoder, Response, StatusCode};
// リクエストをデコード
let mut decoder = RequestDecoder::new();
// 受信データを feed...
// decoder.feed(&received_data)?;
// if let Some(request) = decoder.decode()? { ... }
fn build() -> Result<Vec<u8>, EncodeError> {
// レスポンスを作成してエンコード
let response = Response::with_status(StatusCode::OK)
.header("Content-Type", "text/plain").unwrap()
.body(b"Hello, World!".to_vec());
response.encode()
}
let bytes = build().unwrap();
// bytes を送信...Re-exports§
pub use status_code::StatusClass;pub use status_code::StatusCode;pub use uri::Scheme;pub use uri::SchemeError;
Modules§
- accept
- Accept 系ヘッダーパース (RFC 9110 Section 12.5)
- auth
- HTTP 認証 (Basic / Digest / Bearer)
- cache
- HTTP キャッシュヘッダー (RFC 9111)
- compression
- 圧縮/展開トレイト (Sans I/O)
- conditional
- 条件付きリクエストヘッダー (RFC 9110)
- content_
disposition - Content-Disposition ヘッダーパース (RFC 6266)
- content_
encoding - Content-Encoding ヘッダーパース (RFC 9110 Section 8.4)
- content_
language - Content-Language ヘッダーパース (RFC 9110 Section 8.5)
- content_
location - Content-Location ヘッダーパース (RFC 9110 Section 8.6)
- content_
type - Content-Type ヘッダーパース (RFC 9110 Section 8.3)
- cookie
- Cookie ヘッダーパース (RFC 6265)
- date
- HTTP-date パース (RFC 9110 Section 5.6.7)
- digest_
fields - Digest Fields (RFC 9530)
- etag
- ETag ヘッダーパース (RFC 9110)
- expect
- Expect ヘッダーパース (RFC 9110 Section 10.1.1)
- host
- Host ヘッダーパース (RFC 9110 Section 7.2)
- multipart
- multipart/form-data パース (RFC 7578)
- range
- Range リクエストヘッダー (RFC 9110)
- request_
target - request-target の形式 (RFC 9112 Section 3.2)
- status_
code - HTTP ステータスコード型
- trailer
- Trailer フィールドパース (RFC 9110 Section 6.6.2)
- upgrade
- Upgrade ヘッダーパース (RFC 9110 Section 7.8)
- uri
- URI パースとパーセントエンコーディング (RFC 3986)
- vary
- Vary ヘッダーパース (RFC 9110 Section 12.5.5)
Structs§
- Decoder
Limits - デコーダーの制限設定
- Header
Name - HTTP ヘッダー名 (RFC 9110 Section 5.1, field-name = token)
- Method
- HTTP メソッド (RFC 9110 Section 9.1, method = token)
- Request
- HTTP リクエスト
- Request
Decoder - HTTP リクエストデコーダー (Sans I/O)
- Request
Encoder - リクエストエンコーダー (圧縮対応)
- Request
Head - リクエストヘッダー(ボディなし)
- Response
- HTTP レスポンス
- Response
Decoder - HTTP レスポンスデコーダー (Sans I/O)
- Response
Encoder - レスポンスエンコーダー (圧縮対応)
- Response
Head - レスポンスヘッダー(ボディなし)
Enums§
- Body
Kind - ボディの種類
- Body
Progress - ボディデコードの進捗
- Encode
Error - HTTP エンコードエラー
- Error
- HTTP パースエラー
- Header
Name Error HeaderNameの構築エラー- Method
Error Methodの構築エラー
Traits§
- Http
Head - HTTP ヘッダー操作のための共通トレイト
Functions§
- encode_
chunk - Chunked Transfer Encoding 用のチャンクをエンコード
- encode_
chunks - 複数のデータを chunked 形式でエンコード
- encode_
request - リクエストをエンコード
- encode_
request_ headers - リクエストヘッダーのみをエンコード (ボディなし)
- encode_
response - レスポンスをエンコード
- encode_
response_ headers - レスポンスヘッダーのみをエンコード (ボディなし)