Skip to content

Commit

Permalink
feat:push text feat
Browse files Browse the repository at this point in the history
  • Loading branch information
ltpp-universe committed Dec 14, 2024
1 parent ed23cd3 commit d517579
Show file tree
Hide file tree
Showing 78 changed files with 82 additions and 22 deletions.
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[![](https://github.com/ltpp-universe/http-request/workflows/Rust/badge.svg)](https://github.com/ltpp-universe/http-request/actions?query=workflow:Rust)

[Official Documentation](https://docs.ltpp.vip/HTTP-REQUEST/)

[Api Docs](https://docs.rs/http-request/latest/http_request/)

> http-request is a lightweight, efficient library for building, sending, and handling HTTP/HTTPS requests in Rust applications. It provides a simple and intuitive API, allowing developers to easily interact with web services, whether they use the "HTTP" or "HTTPS" protocol. The library supports various HTTP methods, custom headers, request bodies, timeout, automatic handling of redirects (including detecting redirect loops), and enhanced response body decoding (both automatic and manual), enabling fast and secure communication. Whether working with secure "HTTPS" connections or standard "HTTP" requests, the library is optimized for performance, minimal resource usage, and easy integration into Rust projects.http-request is a lightweight, efficient library for building, sending, and handling HTTP/HTTPS requests in Rust applications. It provides a simple and intuitive API, allowing developers to easily interact with web services, whether they use the "HTTP" or "HTTPS" protocol. The library supports various HTTP methods, custom headers, request bodies, timeout, automatic handling of redirects (including detecting redirect loops), and enhanced response body decoding (both automatic and manual), enabling fast and secure communication. Whether working with secure "HTTPS" connections or standard "HTTP" requests, the library is optimized for performance, minimal resource usage, and easy integration into Rust projects.
Expand Down
1 change: 1 addition & 0 deletions src/body/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::Body;
use serde::{Serialize, Serializer};
use std::fmt::{self, Display};
Expand Down
1 change: 1 addition & 0 deletions src/body/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/body/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::collections::HashMap;

/// Represents the body of an HTTP request as a JSON object, stored as a `HashMap`
Expand Down
1 change: 1 addition & 0 deletions src/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use crate::*;
use color_output::*;
use std_macro_extensions::*;
Expand Down
1 change: 1 addition & 0 deletions src/compress/brotli/decode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use brotli::Decompressor;
use std::io::Read;

Expand Down
1 change: 0 additions & 1 deletion src/compress/brotli/helper.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/compress/brotli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// TODO:
pub mod decode;
pub mod helper;
1 change: 1 addition & 0 deletions src/compress/constant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// A constant representing the "gzip" compression algorithm.
///
/// This constant holds the string value `"gzip"`, which is commonly used to refer to the GZIP compression format.
Expand Down
1 change: 1 addition & 0 deletions src/compress/deflate/decode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use flate2::read::DeflateDecoder;
use std::io::{BufReader, Read};

Expand Down
1 change: 0 additions & 1 deletion src/compress/deflate/helper.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/compress/deflate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// TODO:
pub mod decode;
pub mod helper;
1 change: 1 addition & 0 deletions src/compress/gzip/decode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use flate2::read::GzDecoder;
use std::io::BufReader;
use std::io::Read;
Expand Down
1 change: 0 additions & 1 deletion src/compress/gzip/helper.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/compress/gzip/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// TODO:
pub mod decode;
pub mod helper;
1 change: 1 addition & 0 deletions src/compress/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::str::FromStr;

use super::{
Expand Down
1 change: 1 addition & 0 deletions src/compress/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
pub mod brotli;
pub mod constant;
pub mod deflate;
Expand Down
1 change: 1 addition & 0 deletions src/compress/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
#[derive(Debug, PartialEq, Eq)]
pub enum Compress {
Gzip,
Expand Down
1 change: 1 addition & 0 deletions src/constant/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// The name of the application.
///
/// This constant represents the name of the application used for
Expand Down
1 change: 1 addition & 0 deletions src/constant/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod common;
pub mod request;
1 change: 1 addition & 0 deletions src/constant/request.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// The default timeout value for HTTP requests, represented in milliseconds.
/// This value is used when no specific timeout is provided, ensuring that requests
/// have a reasonable maximum duration before timing out.
Expand Down
1 change: 1 addition & 0 deletions src/content_type/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::ContentType;
use crate::request::constant::{
APPLICATION_JSON, APPLICATION_XML, FORM_URLENCODED, TEXT_HTML, TEXT_PLAIN,
Expand Down
1 change: 1 addition & 0 deletions src/content_type/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/content_type/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// Represents different types of HTTP content types, such as JSON, XML, plain text, HTML,
/// form URL encoded, and an unknown type.
#[derive(Debug, PartialEq, Eq)]
Expand Down
1 change: 1 addition & 0 deletions src/global_trait/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#trait::ReadWrite;

/// Provides a blanket implementation for the `ReadWrite` trait.
Expand Down
1 change: 1 addition & 0 deletions src/global_trait/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#trait;
1 change: 1 addition & 0 deletions src/global_trait/trait.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// A trait that combines `std::io::Read` and `std::io::Write`.
///
/// The `ReadWrite` trait serves as a composite trait, requiring that any type implementing it
Expand Down
1 change: 1 addition & 0 deletions src/http_url/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::HttpUrl;
use crate::{protocol::r#type::Protocol, request::error::r#type::Error};
use url::Url as UrlParser;
Expand Down
1 change: 1 addition & 0 deletions src/http_url/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/http_url/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use crate::protocol::r#type::Protocol;

/// A struct representing a parsed URL with various components.
Expand Down
1 change: 1 addition & 0 deletions src/http_version/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::HttpVersion;
use crate::request::constant::{HTTP_VERSION_1_1, HTTP_VERSION_2, UNKNOWN_HTTP_VERSION};
use std::fmt::{self, Display};
Expand Down
1 change: 1 addition & 0 deletions src/http_version/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/http_version/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// Represents the HTTP version used in the request or response.
///
/// This enum is used to specify the HTTP version for HTTP requests and responses.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
pub(crate) mod body;
#[cfg(test)]
mod cfg;
Expand Down
1 change: 1 addition & 0 deletions src/methods/constant.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub static GET: &str = "GET";
pub static POST: &str = "POST";
7 changes: 3 additions & 4 deletions src/methods/impl.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::fmt::{self, Display};

use crate::methods::constant::{GET, POST};

// TODO:
use super::r#type::Methods;
use crate::methods::constant::{GET, POST};
use std::fmt::{self, Display};

impl Default for Methods {
fn default() -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/methods/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
pub mod constant;
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/methods/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// Defines the `Methods` enum, representing HTTP request methods.
///
/// The `Methods` enum includes commonly used HTTP methods such as `GET` and `POST`.
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::request::constant::{HTTP, HTTPS};

// TODO:
use super::r#type::Protocol;
use crate::request::constant::{HTTP, HTTPS};
use std::{
fmt::{self, Display},
str::FromStr,
Expand Down
1 change: 1 addition & 0 deletions src/protocol/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/protocol/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// Defines the `Protocol` enum, representing HTTP-related protocols.
///
/// The `Protocol` enum includes:
Expand Down
1 change: 1 addition & 0 deletions src/request/config/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::Config;
use crate::{
constant::request::DEFAULT_TIMEOUT, http_url::r#type::HttpUrl,
Expand Down
1 change: 1 addition & 0 deletions src/request/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/request/config/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use crate::{http_url::r#type::HttpUrl, http_version::r#type::HttpVersion};

/// Configuration for HTTP requests.
Expand Down
1 change: 1 addition & 0 deletions src/request/constant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// A carriage return and newline character sequence (`\r\n`), used to separate lines in HTTP headers.
pub static HTTP_BR: &str = "\r\n";

Expand Down
4 changes: 2 additions & 2 deletions src/request/error/impl.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// TODO:
use super::r#type::Error;
use std::{
error::Error as StdError,
fmt::{self, Display},
};

use super::r#type::Error;

impl StdError for Error {}

impl Display for Error {
Expand Down
1 change: 1 addition & 0 deletions src/request/error/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/request/error/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// Represents different types of errors that can occur in the application.
///
/// The `Error` enum defines various error types related to HTTP requests, network connections, and TLS operations.
Expand Down
1 change: 1 addition & 0 deletions src/request/header/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// TODO:
pub mod r#type;
1 change: 1 addition & 0 deletions src/request/header/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::collections::HashMap;

/// A type alias for a `HashMap<String, String>`, representing the headers of an HTTP request or response.
Expand Down
1 change: 1 addition & 0 deletions src/request/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
pub mod config;
pub mod constant;
pub mod error;
Expand Down
1 change: 1 addition & 0 deletions src/request/request/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::HttpRequest;
use crate::{
body::r#type::Body,
Expand Down
1 change: 1 addition & 0 deletions src/request/request/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/request/request/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use crate::{
body::r#type::Body,
methods::r#type::Methods,
Expand Down
4 changes: 2 additions & 2 deletions src/request/request_builder/impl.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::Arc;

// TODO:
use super::r#type::RequestBuilder;
use crate::{
body::r#type::{Body, BodyBinary, BodyJson, BodyText},
http_version::r#type::HttpVersion,
methods::r#type::Methods,
request::{header::r#type::Header, r#type::BoxHttpRequest, request::r#type::HttpRequest},
};
use std::sync::Arc;

impl Default for RequestBuilder {
fn default() -> Self {
Expand Down
1 change: 1 addition & 0 deletions src/request/request_builder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/request/request_builder/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use crate::request::request::r#type::HttpRequest;

/// Builder pattern for constructing `Request` instances.
Expand Down
1 change: 1 addition & 0 deletions src/request/tmp/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::Tmp;
use std::collections::HashSet;

Expand Down
1 change: 1 addition & 0 deletions src/request/tmp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/request/tmp/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::collections::HashSet;

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
1 change: 1 addition & 0 deletions src/request/trait.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// Trait representing an HTTP request.
///
/// Provides a method for sending an HTTP request and obtaining the result.
Expand Down
2 changes: 2 additions & 0 deletions src/request/type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// TODO:
use super::r#trait::Request;
use crate::request::error::r#type::Error;
use crate::response::r#type::BoxHttpResponse;

/// Type alias for `Result<BoxHttpResponse, Error>`
pub type RequestResult = Result<BoxHttpResponse, Error>;

Expand Down
1 change: 1 addition & 0 deletions src/response/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
pub mod response_binary;
pub mod response_header;
pub mod response_text;
Expand Down
1 change: 1 addition & 0 deletions src/response/response_binary/impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::r#type::HttpResponseBinary;
use crate::{
compress::r#type::Compress,
Expand Down
1 change: 1 addition & 0 deletions src/response/response_binary/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/response/response_binary/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::collections::HashMap;

/// A struct representing an HTTP response.
Expand Down
1 change: 1 addition & 0 deletions src/response/response_header/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// TODO:
pub mod r#type;
1 change: 1 addition & 0 deletions src/response/response_header/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::collections::HashMap;

/// A type alias for a `HashMap<String, String>`, representing the headers of an HTTP request or response.
Expand Down
4 changes: 2 additions & 2 deletions src/response/response_text/impl.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::collections::HashMap;

// TODO:
use super::r#type::HttpResponseText;
use crate::{
compress::r#type::Compress,
http_version::r#type::HttpVersion,
response::{r#trait::Response, response_binary::r#type::HttpResponseBinary},
status_code::r#type::StatusCode,
};
use std::collections::HashMap;

/// Implements the `Response` trait for `HttpResponseText`.
///
Expand Down
1 change: 1 addition & 0 deletions src/response/response_text/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
1 change: 1 addition & 0 deletions src/response/response_text/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use std::collections::HashMap;

/// A struct representing an HTTP response.
Expand Down
1 change: 1 addition & 0 deletions src/response/trait.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
/// A trait representing common behaviors for HTTP response types.
///
/// This trait provides methods for transforming an HTTP response into
Expand Down
1 change: 1 addition & 0 deletions src/response/type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO:
use super::{
r#trait::Response, response_binary::r#type::HttpResponseBinary,
response_text::r#type::HttpResponseText,
Expand Down
4 changes: 2 additions & 2 deletions src/status_code/impl.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// TODO:
use super::r#type::StatusCode;
use std::{
fmt::{self, Display},
str::FromStr,
};

use super::r#type::StatusCode;

/// The `StatusCode` enum represents the HTTP status codes.
///
/// It maps common HTTP status codes to their respective meanings. It provides methods to retrieve
Expand Down
1 change: 1 addition & 0 deletions src/status_code/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO:
pub mod r#impl;
pub mod r#type;
Loading

0 comments on commit d517579

Please sign in to comment.