rust-web-server 17.19.0

Static file web server and HTTP toolkit written in Rust. Supports HTTP/3, HTTP/2, and HTTP/1.1. HTTP/3 and HTTP/2 require a TLS certificate; without one the server falls back to plain HTTP/1.1 automatically.
Documentation
use std::collections::HashMap;
use crate::symbol::SYMBOL;
use crate::url::URL;

/// Parser and serialiser for `application/x-www-form-urlencoded` bodies.
pub struct FormUrlEncoded;

impl FormUrlEncoded {
    /// Parses a URL-encoded body into a `HashMap` of field name → value.
    pub fn parse(data: Vec<u8>) -> Result<HashMap<String, String>, String> {
        let boxed_string = String::from_utf8(data);
        if boxed_string.is_err() {
            let message = boxed_string.err().unwrap().to_string();
            return Err(message)
        }
        let string = boxed_string.unwrap();
        let string = string.replace(|x : char | x.is_ascii_control(), SYMBOL.empty_string).trim().to_string();


        Ok(URL::parse_query(&string))
    }

    pub fn generate(map: HashMap<String, String>) -> String {
        URL::build_query(map)
    }
}