[Add] TCP server to core MTP (HTTP/1.1 & HTTP/2) compatibility
All checks were successful
CI / checks (push) Successful in 5m29s
All checks were successful
CI / checks (push) Successful in 5m29s
This commit is contained in:
parent
04760fd88d
commit
00f0aaeeff
21 changed files with 1627 additions and 677 deletions
|
|
@ -3,9 +3,9 @@ use http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, Uri};
|
|||
use std::net::SocketAddr;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
/// An owned HTTP/3 request passed to a route handler.
|
||||
/// An owned HTTP request passed to a route handler.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Http3Request {
|
||||
pub struct HttpRequest {
|
||||
pub method: Method,
|
||||
pub uri: Uri,
|
||||
pub headers: HeaderMap,
|
||||
|
|
@ -13,15 +13,15 @@ pub struct Http3Request {
|
|||
pub remote_addr: SocketAddr,
|
||||
}
|
||||
|
||||
/// A buffered HTTP/3 response returned from a route handler.
|
||||
pub struct Http3Response {
|
||||
/// An HTTP response returned from a route handler.
|
||||
pub struct HttpResponse {
|
||||
pub status: StatusCode,
|
||||
pub headers: HeaderMap,
|
||||
pub body: Vec<Bytes>,
|
||||
pub(crate) stream: Option<mpsc::Receiver<Bytes>>,
|
||||
}
|
||||
|
||||
impl Http3Response {
|
||||
impl HttpResponse {
|
||||
pub fn new(status: StatusCode) -> Self {
|
||||
Self {
|
||||
status,
|
||||
|
|
@ -68,19 +68,25 @@ impl Http3Response {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Http3Response {
|
||||
impl Default for HttpResponse {
|
||||
fn default() -> Self {
|
||||
Self::new(StatusCode::OK)
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated(note = "use HttpRequest")]
|
||||
pub type Http3Request = HttpRequest;
|
||||
|
||||
#[deprecated(note = "use HttpResponse")]
|
||||
pub type Http3Response = HttpResponse;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn response_collects_headers_and_body_chunks() {
|
||||
let response = Http3Response::new(StatusCode::CREATED)
|
||||
let response = HttpResponse::new(StatusCode::CREATED)
|
||||
.header("content-type", "text/plain")
|
||||
.body("hello")
|
||||
.body(" world");
|
||||
|
|
|
|||
Loading…
Reference in a new issue