commit 2625e3b992c23567e34d9dc1be8c364cd637a2ae from: Murilo Ijanc date: Fri Apr 24 19:56:01 2026 UTC initial import of http, a single-file HTTP library commit - /dev/null commit + 2625e3b992c23567e34d9dc1be8c364cd637a2ae blob - /dev/null blob + 6b993920204f2af98037cb67012b0c1ce66f59d7 (mode 644) --- /dev/null +++ .gitignore @@ -0,0 +1,2 @@ +build +refs blob - /dev/null blob + df99c69198f5813df5fc3eaa007a2af0e60a7bbd (mode 644) --- /dev/null +++ .rustfmt.toml @@ -0,0 +1 @@ +max_width = 80 blob - /dev/null blob + 32f3292e31bbd5acf75b7671b679e9017828078c (mode 644) --- /dev/null +++ LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2026 Murilo Ijanc' + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. blob - /dev/null blob + 543c1daefddb255476d8b3868e27583d42788de9 (mode 644) --- /dev/null +++ Makefile @@ -0,0 +1,70 @@ +# +# Copyright (c) 2026 Murilo Ijanc' +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +RUSTC ?= $(shell rustup which rustc 2>/dev/null || which rustc) +RUSTFLAGS ?= -C opt-level=2 +VERSION = 0.1.0 + +BUILD = build +SRC = http.rs +LIB = $(BUILD)/libhttp.rlib +TEST = $(BUILD)/http-test + +CLIPPY ?= $(shell rustup which clippy-driver 2>/dev/null) +RUSTFMT ?= $(shell rustup which rustfmt 2>/dev/null) +RUSTDOC ?= $(shell rustup which rustdoc 2>/dev/null || which rustdoc) + +DOC = $(BUILD)/doc/http/index.html + +.PHONY: all clean test fmt-check clippy ci doc + +all: $(LIB) + +$(LIB): $(SRC) + mkdir -p $(BUILD) + HTTP_VERSION=$(VERSION) $(RUSTC) --edition 2024 \ + --crate-type rlib --crate-name http $(RUSTFLAGS) \ + -o $@ $< + +$(TEST): $(SRC) + mkdir -p $(BUILD) + HTTP_VERSION=$(VERSION) $(RUSTC) --edition 2024 \ + --test --crate-name http -o $@ $< + +test: $(TEST) + $(TEST) + +fmt-check: + $(RUSTFMT) --edition 2024 --check $(SRC) + +clippy: + mkdir -p $(BUILD) + HTTP_VERSION=$(VERSION) $(CLIPPY) --edition 2024 \ + --crate-type rlib --crate-name http \ + -W clippy::all -o $(BUILD)/http.clippy $(SRC) + @rm -f $(BUILD)/http.clippy + +ci: fmt-check clippy $(LIB) test + +$(DOC): $(SRC) + mkdir -p $(BUILD) + $(RUSTDOC) --edition 2024 --crate-name http \ + -o $(BUILD)/doc $(SRC) + +doc: $(DOC) + +clean: + rm -rf $(BUILD) blob - /dev/null blob + c502e918967f28a2a7c3fa55abe3211ca70cae17 (mode 644) --- /dev/null +++ README.md @@ -0,0 +1,42 @@ +http - minimal HTTP/1.0 and HTTP/1.1 library +============================================= +http is a minimal, single-file HTTP library written in Rust, conforming +to RFC 1945 (HTTP/1.0) and RFC 2616 (HTTP/1.1). It is meant to be +dropped into another project's source tree, or linked as a plain rlib. + + +Requirements +------------ +In order to build http you need rustc (edition 2024). + + +Installation +------------ +There are two ways to use http in another Rust project. + +Drop-in source. Copy http.rs into your project and declare it as a +module: + + mod http; + +Linked rlib. Build the library with make(1) and pass it to rustc: + + $ make + $ rustc --extern http=build/libhttp.rlib -L build main.rs + + +Standards +--------- +- RFC 1945 (HTTP/1.0) +- RFC 2616 (HTTP/1.1) + + +Download +-------- + got clone ssh://anon@ijanc.org/http + git clone https://git.ijanc.org/http.git + + +License +------- +ISC - see LICENSE. blob - /dev/null blob + 1eea2e11450dfca287e834eb2402ceec265f3da1 (mode 644) --- /dev/null +++ http.rs @@ -0,0 +1,20 @@ +// vim: set tw=79 cc=80 ts=4 sw=4 sts=4 et : +// +// Copyright (c) 2026 Murilo Ijanc' +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +//! Minimal HTTP/1.0 and HTTP/1.1 library. +//! +//! Conforms to RFC 1945 (HTTP/1.0) and RFC 2616 (HTTP/1.1).