commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
900a113266493f8ea6b01e30f929f05dd21f1b8c | Martin Algesten | 2024-07-20T08:43:28 | Fix bug in chunk meta reading | diff --git a/hoot/src/chunk.rs b/hoot/src/chunk.rs
index a65caa0..87a48d7 100644
--- a/hoot/src/chunk.rs
+++ b/hoot/src/chunk.rs
@@ -66,9 +66,21 @@ impl Dechunker {
None => return Ok(false),
};
- let len_end = src.iter().position(|c| *c == b';').unwrap_or(i);
+ const SANITY_CHECK: ... | 1 | 23 | 2 |
f69d7ab98ae9dedb1e6f8dca8706d28274a2fe07 | Martin Algesten | 2024-07-18T19:16:09 | public request/response parsers | diff --git a/hoot/src/error.rs b/hoot/src/error.rs
index d6ea287..991b750 100644
--- a/hoot/src/error.rs
+++ b/hoot/src/error.rs
@@ -82,6 +82,12 @@ pub enum Error {
#[error("body is chunked")]
BodyIsChunked,
+
+ #[error("http request is missing a method")]
+ RequestMissingMethod,
+
+ #[error("http ... | 3 | 58 | 2 |
6d62c31ff22b8edfc01da1da7d584e625466ad0f | Martin Algesten | 2024-07-18T19:07:28 | Move httparse headers into parser | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 6ce5e45..11dfab8 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -438,9 +438,8 @@ impl<'a, B> Call<RecvResponse, B> {
/// Once the response headers are succesfully read, use [`Call::into_body()`] to proceed
/// reading ... | 3 | 8 | 8 |
89aa3e83610ad00d589079bff910a67a4db53f5f | Martin Algesten | 2024-07-14T10:41:41 | BodyMode derive Debug | diff --git a/hoot/src/body.rs b/hoot/src/body.rs
index c35c1b6..8be3213 100644
--- a/hoot/src/body.rs
+++ b/hoot/src/body.rs
@@ -193,7 +193,7 @@ pub(crate) enum BodyReader {
CloseDelimited,
}
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BodyMode {
/// No bo... | 1 | 1 | 1 |
7a2ec4a0cc1612f993d47b87c4674d678dfd7625 | Martin Algesten | 2024-07-14T09:58:51 | Expose BodyMode | diff --git a/hoot/src/body.rs b/hoot/src/body.rs
index 6497805..c35c1b6 100644
--- a/hoot/src/body.rs
+++ b/hoot/src/body.rs
@@ -193,7 +193,31 @@ pub(crate) enum BodyReader {
CloseDelimited,
}
+#[derive(Clone, Copy, PartialEq, Eq)]
+pub enum BodyMode {
+ /// No body is expected either due to the status or me... | 5 | 48 | 3 |
d1c81b8af73abebaaede11def177df62c5feef86 | Martin Algesten | 2024-07-13T14:57:27 | Move call inspection to Flow<SendRequest> | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 5ce0be9..f236cdd 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -98,7 +98,11 @@ impl<State, B> Call<State, B> {
})
}
- fn analyze_request(&mut self) -> Result<(), Error> {
+ pub(crate) fn analyze_request(&m... | 3 | 39 | 23 |
daed35f8a6d639474d21418d55a70098f501cad8 | Martin Algesten | 2024-07-13T14:37:48 | Methods to debug request in Flow<Prepare> | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index bda5306..b249216 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -151,6 +151,10 @@ impl<Body> AmendedRequest<Body> {
self.request.method()
}
+ pub(crate) fn version(&self) -> Version {
+ self... | 2 | 19 | 1 |
d58448aca67fd12d288593ce5ec0d796dc3cd889 | Martin Algesten | 2024-07-13T14:30:51 | Remove logging | diff --git a/Cargo.lock b/Cargo.lock
index f037621..0f4af07 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -29,7 +29,6 @@ version = "0.2.0"
dependencies = [
"http",
"httparse",
- "log",
"smallvec",
"thiserror",
"url",
@@ -68,12 +67,6 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.... | 6 | 20 | 68 |
9b6dc266ffc8ee97978672a18e9fec18fa002e5d | Martin Algesten | 2024-07-13T11:42:13 | Log prelude to DEBUG level | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 5ce0be9..896accc 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -216,6 +216,9 @@ impl<'a, B> Call<WithoutBody, B> {
let output_used = w.len();
+ // Unwrap is ok because we will only write ASCII
+ debug... | 1 | 10 | 0 |
02992fea818a3d9a80a8a0f20967223cf84987bd | Martin Algesten | 2024-07-12T09:57:12 | Unset more headers on redirect | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index 6bf8d2f..bda5306 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -41,13 +41,10 @@ pub(crate) struct AmendedRequest<Body> {
uri: Option<Uri>,
headers: SmallVec<[(HeaderName, HeaderValue); MAX_EXTRA_HEADERS]>,... | 3 | 65 | 13 |
994e1ff92002d9c85f7d0a18022b68f8562d8a2f | Martin Algesten | 2024-07-11T16:09:19 | Flow<Redirect> expose status() | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index 1cb2878..09c313e 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -532,6 +532,10 @@ impl<B> Flow<B, Redirect> {
Ok(Some(next))
}
+ pub fn status(&self) -> StatusCode {
+ self.inner.status.unwrap()
+ }
... | 1 | 4 | 0 |
e2917b98e2a48630dd2d1b6bd2634eb1fffc8547 | Martin Algesten | 2024-07-11T16:01:23 | Flow::method() in Prepare | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index 44ead95..1cb2878 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -128,6 +128,10 @@ impl<B> Flow<B, Prepare> {
Ok(Flow::wrap(inner))
}
+ pub fn method(&self) -> &Method {
+ self.call().request().method()
... | 1 | 4 | 0 |
2133704f4f57cc7524eaf352a1ba4fbb34c4b48e | Martin Algesten | 2024-07-11T15:49:58 | impl Debug for Flow | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index 55e7b08..44ead95 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -12,14 +12,29 @@ use crate::Error;
use super::holder::CallHolder;
pub mod state {
- pub struct Prepare(());
- pub struct SendRequest(());
- pub struct ... | 1 | 31 | 8 |
ff28e79951284bd27ef87b62af07a382da1172fb | Martin Algesten | 2024-07-11T15:36:14 | Redirect with content-length: 0 should not wait for body | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 5d871a8..5ce0be9 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -156,7 +156,10 @@ struct BodyState {
impl BodyState {
fn need_response_body(&self) -> bool {
- !matches!(self.reader, Some(BodyReader::NoBody))
+ ... | 2 | 16 | 1 |
3a7dafbaa7284da9e85267d8d9df9fd19360be2e | Martin Algesten | 2024-07-10T16:16:04 | consume_direct_write to avoid memcopy | diff --git a/hoot/src/body.rs b/hoot/src/body.rs
index 05cbe3c..9a7c694 100644
--- a/hoot/src/body.rs
+++ b/hoot/src/body.rs
@@ -134,6 +134,20 @@ impl BodyWriter {
_ => None,
}
}
+
+ pub(crate) fn consume_direct_write(&mut self, amount: usize) {
+ match &mut self.mode {
+ ... | 4 | 38 | 0 |
d3ad47bb5adeabc5cae1ba908589f552651cd825 | Martin Algesten | 2024-07-10T15:58:53 | calculate_output_overhead | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 7d310b9..2935c88 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -270,10 +270,7 @@ impl<'a, B> Call<WithBody, B> {
/// );
/// ```
pub fn write(&mut self, input: &[u8], output: &mut [u8]) -> Result<(usize, usize), E... | 3 | 36 | 4 |
2e2eac528c3f37cda41101640408c3b001620036 | Martin Algesten | 2024-07-07T19:47:03 | Take ownership of Request | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index 5aaf337..6bf8d2f 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -1,3 +1,5 @@
+use std::mem;
+
use http::{HeaderName, HeaderValue, Method, Request, Uri, Version};
use smallvec::SmallVec;
use url::Url;
@@ -34,20 +36... | 6 | 123 | 120 |
3e52ff18903b304dd152d4dbf70583510b872ede | Martin Algesten | 2024-07-07T13:49:06 | Expose must_close_connection also in Redirect | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index 6cd4087..7e81f01 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -491,6 +491,17 @@ impl<'a, B> Flow<'a, B, Redirect> {
Ok(Some(next))
}
+ pub fn must_close_connection(&self) -> bool {
+ let maybe_reason ... | 1 | 11 | 0 |
040c74c0f8169d48937ce80563be032bb43d910e | Martin Algesten | 2024-07-07T12:57:12 | Rename as_new_state -> as_new_flow | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index 43817dd..6cd4087 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -408,7 +408,7 @@ pub enum RecvBodyResult<'a, B> {
// //////////////////////////////////////////////////////////////////////////////////////////// REDIRECT
impl<... | 2 | 9 | 9 |
a90a3c30fd7dfa073429039a1750438289a743b9 | Martin Algesten | 2024-07-07T12:56:13 | RedirectAuthHeaders is Copy | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index d2448a5..43817dd 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -510,7 +510,7 @@ fn can_redirect_auth_header(prev: &Uri, next: &Uri) -> bool {
/// * `SameHost` send the authorization header in redirects only if the host of the ... | 1 | 1 | 1 |
9fd0bd17a1ee67421a48bfd851cddc51258cc267 | Martin Algesten | 2024-07-03T15:34:43 | Reorganize modules | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index ef5c6a9..9490caa 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -58,7 +58,7 @@ impl<'a, B> Call<'a, (), B> {
/// a [`Call`] instance that does not expect a user provided body.
///
/// ```
- /// # use hoot::clie... | 7 | 14 | 22 |
b741a5a38b5598dc362e49498dc88d2f19cc8c2c | Martin Algesten | 2024-07-03T15:10:01 | Introduce "useless" http crate body type param | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index a49af00..5aaf337 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -34,16 +34,16 @@ use super::MAX_EXTRA_HEADERS;
/// 9. Changing the `Method` when following redirects.
/// 10. Changing the `Uri` when following redir... | 5 | 95 | 95 |
903fc511fa7147e5d9b9768ea903a3a1db0ab82c | Martin Algesten | 2024-07-02T20:30:14 | Test state Cleanup | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index 47f3c24..baba82e 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -29,6 +29,7 @@ pub struct Flow<'a, State> {
}
// pub(crate) for tests to inspect state
+#[derive(Debug)]
pub(crate) struct Inner<'a> {
pub call: CallHolde... | 7 | 238 | 56 |
70e352c7821918700a63f08915cda6941bfdb14d | Martin Algesten | 2024-07-01T20:44:54 | More tests for redirect authorize headers | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index fa78669..a49af00 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -75,7 +75,10 @@ impl<'a> AmendedRequest<'a> {
let r = &self.request;
(
r.method(),
- r.uri().path_and_query().... | 3 | 61 | 6 |
535c17f16d481da3ec70b0580c5e755a38f427bb | Martin Algesten | 2024-07-01T20:34:07 | Fixes to call initialization | diff --git a/hoot/src/analyze.rs b/hoot/src/analyze.rs
deleted file mode 100644
index 7b0fb26..0000000
--- a/hoot/src/analyze.rs
+++ /dev/null
@@ -1,156 +0,0 @@
-use http::{HeaderName, HeaderValue, Method, Request, StatusCode, Version};
-
-use crate::body::BodyWriter;
-use crate::util::compare_lowercase_ascii;
-use cra... | 11 | 380 | 251 |
3e24ccf68bd61ada8d3275a1b26731f0d7defe69 | Martin Algesten | 2024-07-01T16:57:18 | Test redircect method changes | diff --git a/hoot/src/analyze.rs b/hoot/src/analyze.rs
index 6bf51b3..7b0fb26 100644
--- a/hoot/src/analyze.rs
+++ b/hoot/src/analyze.rs
@@ -61,11 +61,11 @@ impl<'a, I: Iterator<Item = (&'a HeaderName, &'a HeaderValue)>> HeaderIterExt fo
pub(crate) trait StatusExt {
/// Detect 307/308 redirect
- fn is_redire... | 5 | 117 | 19 |
3feddf1025b4763c42f02ef13afcd9875b16d43e | Martin Algesten | 2024-07-01T16:17:13 | Move Call type states | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 994453a..6ae0e74 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -11,7 +11,26 @@ use crate::util::Writer;
use crate::Error;
use super::amended::AmendedRequest;
-use super::{RecvBody, RecvResponse, WithBody, WithoutBody, MAX_R... | 3 | 24 | 22 |
70ddaa0003af62a012ab208b1244af7877e09f91 | Martin Algesten | 2024-07-01T16:09:56 | Option for .proceed() that can fail | diff --git a/hoot/src/client/flow.rs b/hoot/src/client/flow.rs
index e932c0f..07f5915 100644
--- a/hoot/src/client/flow.rs
+++ b/hoot/src/client/flow.rs
@@ -149,15 +149,17 @@ impl<'a> Flow<'a, SendRequest> {
}
}
- pub fn proceed(mut self) -> SendRequestResult<'a> {
- assert!(self.can_proceed()... | 4 | 42 | 34 |
8d49f6f67eff26b53a054b9756e36b04534f9f3d | Martin Algesten | 2024-06-30T20:19:24 | More tests | diff --git a/Cargo.lock b/Cargo.lock
index 4461c2a..f037621 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14,6 +14,15 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+[[package]]
+name = "form_urlencod... | 9 | 300 | 67 |
8d7ada62e3a80ee97a25c48619a6e6abba66eeb2 | Martin Algesten | 2024-06-30T11:01:06 | Rename State -> Flow | diff --git a/hoot/src/client/state.rs b/hoot/src/client/flow.rs
similarity index 88%
rename from hoot/src/client/state.rs
rename to hoot/src/client/flow.rs
index 0912351..33675e4 100644
--- a/hoot/src/client/state.rs
+++ b/hoot/src/client/flow.rs
@@ -10,8 +10,6 @@ use crate::Error;
use super::holder::CallHolder;
-... | 7 | 156 | 158 |
4865869470080a001aa53376137598842d562d71 | Martin Algesten | 2024-06-30T10:55:45 | Rename test files | diff --git a/hoot/src/client/mod.rs b/hoot/src/client/mod.rs
index 7ca8c78..5aa7cb3 100644
--- a/hoot/src/client/mod.rs
+++ b/hoot/src/client/mod.rs
@@ -243,6 +243,8 @@ mod holder;
#[cfg(test)]
mod test;
+// TODO(martin): let's move these type states somewhere more relevant.
+
/// Type state for requests without b... | 7 | 48 | 4 |
167115fb9ae45a96ddcec9c74adf23315bd99e29 | Martin Algesten | 2024-06-30T10:37:28 | Start of test suite | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index 7b41216..673d83c 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -102,6 +102,17 @@ impl<'a> AmendedRequest<'a> {
self.headers().count()
}
+ #[cfg(test)]
+ pub fn headers_vec(&self) -> Vec<(&str, ... | 11 | 529 | 20 |
e59593d73abac0b68e1f4704e17ac2de6241f213 | Martin Algesten | 2024-06-30T08:32:31 | Move Call tests | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index 1f96a31..c621401 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -477,3 +477,296 @@ impl fmt::Debug for Phase {
}
}
}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+
+ use std::str;
+
+ use http::{Method, Re... | 2 | 293 | 293 |
ed759b3528a59a6987930e1c3dd88f0f26e27cca | Martin Algesten | 2024-06-29T22:20:38 | Full State example | diff --git a/hoot/src/client/mod.rs b/hoot/src/client/mod.rs
index 352a339..56ae560 100644
--- a/hoot/src/client/mod.rs
+++ b/hoot/src/client/mod.rs
@@ -5,6 +5,7 @@
//! ```
//! use hoot::client::State;
//! use hoot::http::Request;
+//! use hoot::client::results::*;
//!
//! let request = Request::put("https://examp... | 2 | 129 | 8 |
6ca59de9875da8b4ffe1f05b68686d6118d6d5d6 | Martin Algesten | 2024-06-29T21:24:56 | Fix missing \r\n after header | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index bc577fd..1f96a31 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -167,7 +167,7 @@ impl<'a> Call<'a, WithoutBody> {
/// let n = call.write(&mut output).unwrap();
/// let s = std::str::from_utf8(&output[..n]).unwrap();
... | 2 | 77 | 19 |
2d04da950496d2a676a74d7662dd39af39277800 | Martin Algesten | 2024-06-29T20:42:51 | SmallVec all the way | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
index 8203c58..7b41216 100644
--- a/hoot/src/client/amended.rs
+++ b/hoot/src/client/amended.rs
@@ -1,7 +1,10 @@
use http::{HeaderName, HeaderValue, Method, Request, Uri, Version};
+use smallvec::SmallVec;
use crate::Error;
+use super::MAX_EXTRA... | 3 | 14 | 8 |
49bdfa4eb812e0f88cf5fed7b778314fd9f8b267 | Martin Algesten | 2024-06-29T17:34:35 | Handle delayed 100-continue status | diff --git a/hoot/src/analyze.rs b/hoot/src/analyze.rs
index 181915a..6bf51b3 100644
--- a/hoot/src/analyze.rs
+++ b/hoot/src/analyze.rs
@@ -46,12 +46,17 @@ impl MethodExt for Method {
pub(crate) trait HeaderIterExt {
fn has(self, key: &str, value: &str) -> bool;
+ fn has_expect_100(self) -> bool;
}
impl... | 3 | 27 | 5 |
c8193391d8a48b562aa93adb1be5ddc114093335 | Martin Algesten | 2024-06-29T10:59:41 | Call stop after sending headers | diff --git a/hoot/src/client/call.rs b/hoot/src/client/call.rs
index aa507eb..a398981 100644
--- a/hoot/src/client/call.rs
+++ b/hoot/src/client/call.rs
@@ -222,12 +222,13 @@ impl<'a> Call<'a, WithBody> {
///
/// // Send body
/// let mut output = vec![0; 1024];
- /// let (i, n1) = call.write(body, &mu... | 3 | 79 | 50 |
cc77778b2e30749dbb14ccec091d09ef46ea49a7 | Martin Algesten | 2024-06-29T09:20:02 | Refactor out AmendedRequest | diff --git a/hoot/src/client/amended.rs b/hoot/src/client/amended.rs
new file mode 100644
index 0000000..eae847e
--- /dev/null
+++ b/hoot/src/client/amended.rs
@@ -0,0 +1,131 @@
+use std::sync::OnceLock;
+
+use http::{HeaderName, HeaderValue, Method, Request, Uri, Version};
+
+use crate::Error;
+
+/// `Request` with am... | 5 | 167 | 76 |
734341394d09127c33aa482f7c976f2e4f7a7f3a | Martin Algesten | 2024-04-20T06:12:13 | Bump to 0.2.0 | diff --git a/Cargo.lock b/Cargo.lock
index 24d0183..0fafd74 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -28,7 +28,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "hoot"
-version = "0.1.4"
+version = "0.2.0"
dependencies = [
"http",
"httparse",
@@ -38,7 +38,... | 5 | 11 | 11 |
b1d2cbbbcfc057739caa93d36dac3eb793a62fea | Martin Algesten | 2024-02-25T07:59:27 | Fix overread bug in limited body | diff --git a/hoot/src/body.rs b/hoot/src/body.rs
index 0519a90..2c6b6f9 100644
--- a/hoot/src/body.rs
+++ b/hoot/src/body.rs
@@ -20,21 +20,17 @@ pub(crate) fn do_read_body<'a, 'b>(
}
// unwrap is ok because we can't be in state RECV_BODY without setting it.
- let bit = match state.recv_body_mode.unwrap()... | 2 | 22 | 9 |
51c903f2c8a4c721bd850b513dd2d362f6225787 | Martin Algesten | 2024-02-24T16:26:10 | Move url to hooturl | diff --git a/Cargo.lock b/Cargo.lock
index 5bc3202..1e30017 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -29,11 +29,16 @@ version = "0.1.5"
dependencies = [
"fastrand",
"hoot",
+ "hooturl",
"serde",
"serde_json",
"thiserror",
]
+[[package]]
+name = "hooturl"
+version = "0.1.4"
+
[[package]]
name = "httpa... | 10 | 36 | 14 |
e786d78c6d39bfb6af3c4d8b5ef3da091086e360 | Martin Algesten | 2024-02-16T06:38:20 | bin: 0.1.5 | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index 0e07b8c..857012a 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -18,7 +18,7 @@ dependencies = [
[[package]]
name = "hootbin"
-version = "0.1.4"
+version = "0.1.5"
dependencies = [
"fastrand",
"hoot",
diff --git a/hootbin/Cargo.toml b/hootb... | 2 | 2 | 2 |
b65e6dfeb3b1b90918c9341543c13a2a5b8a817c | Martin Algesten | 2024-02-16T06:37:53 | Remove hootbin feature | diff --git a/hootbin/Cargo.toml b/hootbin/Cargo.toml
index a42d724..be771b1 100644
--- a/hootbin/Cargo.toml
+++ b/hootbin/Cargo.toml
@@ -11,17 +11,9 @@ repository = "https://github.com/algesten/hoot"
# MSRV
rust-version = "1.61"
-[features]
-# Without the feature json, this library is completely useless,
-# but it'... | 2 | 3 | 27 |
2272c09ea59450d0f64653ca8d7284ad7192d221 | Martin Algesten | 2024-02-16T05:03:17 | bin: version 0.1.4 | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index b95dad5..0e07b8c 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -18,7 +18,7 @@ dependencies = [
[[package]]
name = "hootbin"
-version = "0.1.1"
+version = "0.1.4"
dependencies = [
"fastrand",
"hoot",
diff --git a/hootbin/Cargo.toml b/hootb... | 2 | 2 | 2 |
e8080a647c5b8ae884555a594da479eed5b4305a | Martin Algesten | 2024-02-16T05:02:51 | bin: hoot version 0.1.4 | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index b7930da..b95dad5 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "hoot"
-version = "0.1.3"
+version = "0.1.4"
dependencies = [
"ht... | 2 | 2 | 2 |
80d2852ca312d1d174ac8d0335d4f4860e249d60 | Martin Algesten | 2024-02-16T05:01:19 | bin: feature="json" to disable serde | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index 718612a..b7930da 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -47,9 +47,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "proc-macro2"
-version = "1.0.74"
+version = "1.0.78"
source = "reg... | 3 | 43 | 20 |
b708cc8f5826b30d079efd0c9fc8581d2840a693 | Ethan Pailes | 2024-02-15T21:25:46 | fix soundness issues in unsafe usage
This patch fixes some soundness issues in the unsafe usage.
These issues were unlikely to be able to cause issues in
practice, but could potentially cause issues if doing
something weird like mixing and matching toolchains.
It manages to significantly cut down on the unsafe usage
... | diff --git a/Cargo.lock b/Cargo.lock
index ea5b4db..b7dd4be 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "hoot"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"httparse",
"log",
diff --git a/s... | 6 | 31 | 39 |
5fecc96e14bcc834f9970a97f15b75bd1d7998a1 | Martin Algesten | 2024-01-31T08:50:05 | bin: 0.1.3 | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index ba196fa..718612a 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "hoot"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"ht... | 2 | 4 | 4 |
18436cc1a3ca8e9d9bf194f3be2359a354d3620d | Martin Algesten | 2024-01-31T08:47:55 | bin: MSRV 1.61 | diff --git a/hootbin/Cargo.toml b/hootbin/Cargo.toml
index fa7b3d8..cbe690b 100644
--- a/hootbin/Cargo.toml
+++ b/hootbin/Cargo.toml
@@ -8,6 +8,9 @@ keywords = ["http", "server", "web"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/algesten/hoot"
+# MSRV
+rust-version = "1.61"
+
[dependencies]
fa... | 3 | 20 | 8 |
71272a372fa0efdd569111bc47f636132bf75088 | Martin Algesten | 2024-01-31T08:25:44 | Make private trait pub in private mod | diff --git a/src/types.rs b/src/types.rs
index 433efa7..bda6bf1 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -1,12 +1,14 @@
//! Type state variables
-#![allow(private_bounds)]
-
use crate::HttpVersion;
+use private::Private;
-pub(crate) trait Private {
- fn state_name() -> &'static str;
+mod private {
+ ... | 1 | 6 | 4 |
d6859f9706a7a5c24d7d28cffa03218ddf9786cc | Martin Algesten | 2024-01-20T13:01:17 | bin: cargo.toml | diff --git a/hootbin/Cargo.toml b/hootbin/Cargo.toml
index d62a7a8..fa7b3d8 100644
--- a/hootbin/Cargo.toml
+++ b/hootbin/Cargo.toml
@@ -2,6 +2,11 @@
name = "hootbin"
version = "0.1.0"
edition = "2021"
+authors = ["Martin Algesten <martin@algesten.se>"]
+description = "hoot based library to emulate httpbin"
+keyword... | 1 | 5 | 0 |
9bb15fedb27b1fad91215724b45e2d85b55c15ed | Martin Algesten | 2024-01-20T12:56:09 | bin: hoot 0.1.2 | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index d171a32..ba196fa 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "hoot"
-version = "0.1.0"
+version = "0.1.2"
dependencies = [
"ht... | 2 | 2 | 2 |
d17f7f1121b7603ed61a13877db7ac7e4deecaa1 | Martin Algesten | 2024-01-20T12:51:41 | Fix features for docs.rs | diff --git a/Cargo.toml b/Cargo.toml
index 4010a65..73d742f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/algesten/hoot"
[package.metadata.docs.rs]
-features = "all"
+features = ["all"]
rustdoc-args = ["--cfg", "docsrs"]
[features] | 1 | 1 | 1 |
cef35f3ce7e0f074a7ff732114af559e1e98ecc9 | Martin Algesten | 2024-01-20T10:03:37 | Debug format | diff --git a/src/lib.rs b/src/lib.rs
index 40fcffe..2634376 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -118,8 +118,8 @@ use core::fmt;
impl fmt::Debug for HttpVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- Self::Http10 => write!(f, "Http10"),
- ... | 1 | 2 | 2 |
efae17adbabeb490ae1f2d894f420356a6aff384 | Martin Algesten | 2024-01-20T10:03:26 | fix underflow buffer problem | diff --git a/hootbin/src/buffer.rs b/hootbin/src/buffer.rs
index 8cae08f..c71f074 100644
--- a/hootbin/src/buffer.rs
+++ b/hootbin/src/buffer.rs
@@ -7,6 +7,7 @@ pub struct InputBuffer<T> {
inner: Option<T>,
buffer: [u8; BUFFER_SIZE],
len: usize,
+ did_consume: bool,
}
impl<T: io::Read> InputBuffer... | 1 | 13 | 0 |
646ff3347e7c5c6cb64a1bcdc40d3a2fc9ecc15c | Martin Algesten | 2024-01-20T09:41:53 | Fix body sending | diff --git a/hootbin/Cargo.lock b/hootbin/Cargo.lock
index b63d88d..d171a32 100644
--- a/hootbin/Cargo.lock
+++ b/hootbin/Cargo.lock
@@ -13,6 +13,7 @@ name = "hoot"
version = "0.1.0"
dependencies = [
"httparse",
+ "log",
]
[[package]]
@@ -38,6 +39,12 @@ version = "1.0.10"
source = "registry+https://github.com/... | 3 | 29 | 11 |
e96414569a18f14f368bbb9ff45014c470050aac | Martin Algesten | 2024-01-13T17:23:06 | Prepare toml for release | diff --git a/Cargo.toml b/Cargo.toml
index 3c13f3b..7fbad0b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,11 @@
name = "hoot"
version = "0.1.0"
edition = "2021"
+authors = ["Martin Algesten <martin@algesten.se>"]
+description = "no_std, allocation free http 1.1 library"
+keywords = ["http", "server", "web"]
+l... | 1 | 5 | 0 |
86a7901d42e683392e14d738ca1cc1bd53bfede6 | Martin Algesten | 2024-01-13T17:18:11 | Improve doc | diff --git a/Cargo.toml b/Cargo.toml
index f2f7bb7..3c13f3b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ edition = "2021"
[features]
default = []
+all = ["std"]
std = []
[dependencies]
@@ -12,3 +13,7 @@ httparse = { version = "1.8.0", default-features = false }
[dev-dependencies]
memoffset = "0.... | 5 | 255 | 225 |
f09433191b2660e9d8d727461c2617cda06b7d3c | Martin Algesten | 2024-01-13T16:42:12 | Move traits and simpler body length | diff --git a/src/client/req.rs b/src/client/req.rs
index 762b31c..984b64a 100644
--- a/src/client/req.rs
+++ b/src/client/req.rs
@@ -195,8 +195,10 @@ impl<'a, M: Method, V: Version> Request<'a, SEND_HEADERS, V, M, ()> {
impl<'a, M: MethodWithRequestBody> Request<'a, SEND_HEADERS, HTTP_10, M, ()> {
pub fn with_bod... | 4 | 23 | 9 |
31a97e02985d5f67f2fda8e35b6931af6fb3e728 | Martin Algesten | 2024-01-13T15:05:21 | Make traits public | diff --git a/src/body.rs b/src/body.rs
index 428db3d..408ed46 100644
--- a/src/body.rs
+++ b/src/body.rs
@@ -1,3 +1,4 @@
+use core::ops::Deref;
use core::str;
use crate::chunk::Dechunker;
@@ -28,7 +29,7 @@ pub fn do_read_body<'a, 'b>(
Ok(BodyPart {
input_used: bit.input_used,
- output: bit.ou... | 7 | 140 | 94 |
cc79ee5ec2aca29ea29165cf30c855a0c572ac45 | Martin Algesten | 2024-01-13T10:42:16 | std feature | diff --git a/Cargo.toml b/Cargo.toml
index a0defee..f2f7bb7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ edition = "2021"
[features]
default = []
-std = [] # to run tests
+std = []
[dependencies]
httparse = { version = "1.8.0", default-features = false }
diff --git a/src/body.rs b/src/body.rs
in... | 10 | 98 | 12 |
5e8071ad1d761922ccc9116bfaf0ac5988440ced | Martin Algesten | 2023-12-28T17:09:31 | Url parser | diff --git a/src/error.rs b/src/error.rs
index eb31fc4..6f7bb0a 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,7 +1,10 @@
use core::num::ParseIntError;
use core::str::Utf8Error;
+use crate::url::UrlError;
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[non_exhaustive]
pub enum HootError {
/// The borro... | 3 | 205 | 0 |
4994290f1a70d2efd58a71737b8d21947242ed00 | Martin Algesten | 2023-12-26T08:38:53 | Write chunked body | diff --git a/src/client/req.rs b/src/client/req.rs
index 5c3e77f..71c88fe 100644
--- a/src/client/req.rs
+++ b/src/client/req.rs
@@ -76,7 +76,7 @@ impl<'a, S: State, V: Version, M: Method, B: BodyType> Request<'a, S, V, M, B> {
typ: self.typ,
state: self.state,
},
- ... | 5 | 34 | 11 |
af992748a8c4d567d6c42a70db94853ce0d7fae8 | Martin Algesten | 2023-12-24T11:18:23 | Response modelling | diff --git a/src/server/res.rs b/src/server/res.rs
index e69de29..f2b5e13 100644
--- a/src/server/res.rs
+++ b/src/server/res.rs
@@ -0,0 +1,44 @@
+use core::marker::PhantomData;
+
+use crate::out::Out;
+use crate::vars::body::*;
+use crate::vars::method::*;
+use crate::vars::private::*;
+use crate::vars::state::*;
+use... | 1 | 44 | 0 |
7991c76d4c6a1e692124fa55b201e4818107f865 | Martin Algesten | 2023-12-24T11:05:39 | Read server request body | diff --git a/src/body.rs b/src/body.rs
index 0136a75..ec0bc0b 100644
--- a/src/body.rs
+++ b/src/body.rs
@@ -1,8 +1,78 @@
use core::str;
+use crate::chunk::Dechunker;
use crate::error::Result;
use crate::util::compare_lowercase_ascii;
-use crate::{Header, HootError, Method};
+use crate::{CallState, Header, HootErr... | 4 | 125 | 97 |
d7fe92b1c1e174b6f2bdd565bdddff34c3f71ce9 | Martin Algesten | 2023-12-24T10:50:24 | Start working on reading server request | diff --git a/src/body.rs b/src/body.rs
new file mode 100644
index 0000000..0136a75
--- /dev/null
+++ b/src/body.rs
@@ -0,0 +1,152 @@
+use core::str;
+
+use crate::error::Result;
+use crate::util::compare_lowercase_ascii;
+use crate::{Header, HootError, Method};
+
+pub struct BodyPart<'b> {
+ pub(crate) input_used: u... | 10 | 417 | 179 |
2fa5959ad076f5dd35e1724c4895831d7c8fd7e7 | Martin Algesten | 2023-12-23T18:23:44 | Move stuff to client mod | diff --git a/src/client/mod.rs b/src/client/mod.rs
new file mode 100644
index 0000000..0b8cc4e
--- /dev/null
+++ b/src/client/mod.rs
@@ -0,0 +1,133 @@
+mod req;
+pub use req::{Output, Request, ResumeToken};
+
+mod res;
+pub use res::{BodyPart, Response, Status};
+
+#[cfg(test)]
+mod test {
+ use crate::error::Result... | 4 | 142 | 134 |
db8518d9a7d730d9e961cfe7c2cd5c82261e49fa | Martin Algesten | 2023-12-23T14:40:19 | Our own Header type | diff --git a/Cargo.toml b/Cargo.toml
index b8b0f67..a0defee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,10 @@ edition = "2021"
[features]
default = []
-std = [] # to run tests
+std = [] # to run tests
[dependencies]
httparse = { version = "1.8.0", default-features = false }
+
+[dev-dependencies]
+me... | 5 | 127 | 34 |
e0c50f2ddb1805d806e2d29a86338fa38beb286e | Martin Algesten | 2023-12-22T09:55:04 | Better cast_buf_for_headers | diff --git a/src/error.rs b/src/error.rs
index 411a761..3179aed 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -24,13 +24,6 @@ pub enum HootError {
/// Parsed more headers than provided buffer can contain.
TooManyHeaders,
- /// Parsing headers (for sending or receiving) uses leftover space in the
- /... | 4 | 28 | 46 |
f8377873b5dcacbd32fb88511ae0876bebf7233b | Martin Algesten | 2023-12-21T23:07:26 | Response API tweak | diff --git a/src/lib.rs b/src/lib.rs
index dc67ef1..91145d3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,17 +105,13 @@ mod test {
// ************* READ STATUS LINE *****************
// After calling `send()` above, the resume token can now be converted into a response
- let response = res... | 3 | 89 | 142 |
7d13f2b59ad6789be6a829295c6ffb087c9b210a | Martin Algesten | 2023-12-11T21:15:44 | expose type BodyPart | diff --git a/src/lib.rs b/src/lib.rs
index 0e625b6..dc67ef1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -20,7 +20,7 @@ mod req;
pub use req::{Output, Request, ResumeToken};
mod res;
-pub use res::{Response, Status};
+pub use res::{BodyPart, Response, Status};
// Re-export this
pub use httparse::Header; | 1 | 1 | 1 |
42916eaea36c8a52497b1e2c8fd7b15449324544 | Martin Algesten | 2023-12-11T21:03:57 | better chunk reading | diff --git a/src/chunk.rs b/src/chunk.rs
new file mode 100644
index 0000000..4559b55
--- /dev/null
+++ b/src/chunk.rs
@@ -0,0 +1,162 @@
+use core::str;
+
+use crate::error::Result;
+use crate::parser::find_crlf;
+use crate::HootError;
+
+#[derive(Clone, Copy, PartialEq, Eq)]
+pub(crate) enum Dechunker {
+ Size,
+ ... | 4 | 185 | 57 |
1ade2b818c76984a76404b360e5ad35d1bdaab1b | Martin Algesten | 2023-12-11T18:30:02 | CONNECT and PATCH | diff --git a/src/req.rs b/src/req.rs
index 454e4bb..c2ae1a2 100644
--- a/src/req.rs
+++ b/src/req.rs
@@ -8,11 +8,11 @@ use crate::out::{Out, Writer};
use crate::parser::parse_headers;
use crate::res::RecvBodyMode;
use crate::util::{compare_lowercase_ascii, LengthChecker};
-use crate::vars::body::*;
use crate::vars:... | 3 | 66 | 25 |
c873ce646ced4535a7e6f322bdf27f959fd156c9 | Martin Algesten | 2023-12-11T08:22:26 | More body model | diff --git a/src/error.rs b/src/error.rs
index 73ff53b..411a761 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -78,6 +78,9 @@ pub enum HootError {
/// Invalid byte in HTTP version.
Version,
+
+ /// Did not read body to finish.
+ BodyNotFinished,
}
pub(crate) static OVERFLOW: Result<()> = Err(Hoot... | 3 | 145 | 50 |
74e41197c0def34ac2c9faa018c4906f74787542 | Martin Algesten | 2023-12-10T19:42:21 | use more httparse | diff --git a/src/error.rs b/src/error.rs
index 13ea1b3..73ff53b 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -72,6 +72,12 @@ pub enum HootError {
/// Incoming chunked encoding is incorrect.
IncorrectChunk,
+
+ /// Invalid byte where token is required.
+ Token,
+
+ /// Invalid byte in HTTP versio... | 7 | 99 | 249 |
8b5a670657523d8f1dbe707ede08cc9d0c3048c5 | Martin Algesten | 2023-12-10T18:12:02 | End call | diff --git a/src/req.rs b/src/req.rs
index 4e8acb3..fcef911 100644
--- a/src/req.rs
+++ b/src/req.rs
@@ -37,7 +37,7 @@ pub(crate) struct CallState {
pub send_checker: Option<LengthChecker>,
pub recv_body_mode: Option<RecvBodyMode>,
pub recv_checker: Option<LengthChecker>,
- pub body_complete: bool,
+ ... | 2 | 20 | 4 |
7544e2b8eb89d8df98a422016b2231c9f70c49dc | Martin Algesten | 2023-12-10T18:04:08 | Check http version match | diff --git a/src/parser.rs b/src/parser.rs
index e32d691..9136760 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -11,7 +11,7 @@ pub fn parse_response_line(src: &[u8]) -> Result<ParseResult<Status>> {
const EMPTY_STATUS: Status = Status(HttpVersion::Http11, 0, "");
const EMPTY_PARSE: ParseResult<Status> =... | 2 | 21 | 15 |
ed348520c4a2e1850e53c2a52c286638cf73037b | Martin Algesten | 2023-12-10T17:59:08 | Store away version | diff --git a/src/req.rs b/src/req.rs
index 7d13471..4e8acb3 100644
--- a/src/req.rs
+++ b/src/req.rs
@@ -32,6 +32,7 @@ struct Typ<S: State, V: Version, M: Method, B: BodyType>(
#[derive(Default)]
pub(crate) struct CallState {
+ pub version: Option<HttpVersion>,
pub is_head: Option<bool>,
pub send_check... | 2 | 37 | 2 |
6ce828f3e33ba54ecec0a7b3807a60e3f5966705 | Martin Algesten | 2023-12-10T17:48:53 | Some debug impls | diff --git a/src/req.rs b/src/req.rs
index 0f6cb73..7d13471 100644
--- a/src/req.rs
+++ b/src/req.rs
@@ -437,7 +437,19 @@ mod std_impls {
impl<'a, S: State, V: Version, M: Method, B: BodyType> fmt::Debug for Request<'a, S, V, M, B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- ... | 3 | 40 | 1 |
61c73888da8b4ea8e65a69ab9b005fc0be187d36 | Martin Algesten | 2023-12-10T17:45:56 | Refactor | diff --git a/src/req.rs b/src/req.rs
index 52ebc08..0f6cb73 100644
--- a/src/req.rs
+++ b/src/req.rs
@@ -119,24 +119,12 @@ impl<'a, S: State, V: Version, M: Method, B: BodyType> Request<'a, S, V, M, B> {
}
}
-pub struct Output<'a, S, V, M, B>
-where
- S: State,
- V: Version,
- M: Method,
- B: BodyTy... | 1 | 4 | 28 |
5bfbd3e7ca5f06f47f7ecfd41cd7ad1535e938f4 | Martin Algesten | 2023-12-10T17:36:38 | Read chunked | diff --git a/src/error.rs b/src/error.rs
index 0689f3c..1e3cdbb 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -49,6 +49,12 @@ pub enum HootError {
/// Attempt to send less content than declared in the `Content-Length` header.
SentLessThanContentLength,
+ /// Attempt to send more content than declared i... | 5 | 146 | 5 |
e3ae424966fcfc1b095fa7d43e42aa6e83a10dcd | Martin Algesten | 2023-12-10T16:25:55 | Move LengthChecker | diff --git a/src/req.rs b/src/req.rs
index f89fa59..7e6238c 100644
--- a/src/req.rs
+++ b/src/req.rs
@@ -7,7 +7,7 @@ use crate::error::OVERFLOW;
use crate::out::{Out, Writer};
use crate::parser::parse_headers;
use crate::res::RecvBodyMode;
-use crate::util::compare_lowercase_ascii;
+use crate::util::{compare_lowerca... | 2 | 39 | 39 |
94568be657130dda61e8ff7a6221606793a0f9c7 | Martin Algesten | 2023-12-10T16:21:29 | Split model into req/res | diff --git a/src/lib.rs b/src/lib.rs
index 0c8f236..125ffb7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,25 +1,16 @@
//! no_std, allocation free http library.
// For tests we use std.
-// #![cfg_attr(not(test), no_std)]
+#![cfg_attr(not(test), no_std)]
mod out;
mod util;
-mod model;
-
-pub use model::{HttpV... | 7 | 120 | 739 |
67c2e895e36536ff2cfee593880a4e742d3b7c8b | Martin Algesten | 2023-12-10T16:16:14 | Simpler API | diff --git a/src/lib.rs b/src/lib.rs
index 4334465..0c8f236 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -8,20 +8,28 @@ mod util;
mod model;
-pub use model::{Call, CallState, HttpVersion, Output, Status};
+pub use model::{HttpVersion, Status};
mod vars;
pub use vars::{body, method, state, version};
-mod recv;... | 6 | 725 | 222 |
f4b121fce965fc3899dede9b96a3f60a55b4dc46 | Martin Algesten | 2023-12-10T13:45:45 | recv body | diff --git a/src/lib.rs b/src/lib.rs
index aaf6a65..4334465 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,7 +14,7 @@ mod vars;
pub use vars::{body, method, state, version};
mod recv;
-pub use recv::{Attempt, AttemptHeaders, AttemptStatus};
+pub use recv::{Attempt, AttemptHeaders, AttemptStatus, MaybeBody, MaybeNe... | 4 | 37 | 9 |
5e3d28f00aad34507e5c39782632b74e62abe7ef | Martin Algesten | 2023-12-10T13:11:25 | Read body mode | diff --git a/src/error.rs b/src/error.rs
index 0b1c8f5..0689f3c 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,3 +1,4 @@
+use core::num::ParseIntError;
use core::str::Utf8Error;
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -56,6 +57,12 @@ pub enum HootError {
/// If we attempt to call `.complete()` on an ... | 6 | 145 | 33 |
03b3fe845a6658f5ba36f104a613cb85141c566d | Martin Algesten | 2023-12-10T12:03:35 | Cleanup Attempt | diff --git a/src/lib.rs b/src/lib.rs
index ffed492..aaf6a65 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -92,7 +92,7 @@ mod test {
let call = attempt.proceed().unwrap_stay();
// Try read complete input
- let mut attempt = call.try_read_status(b"HTTP/1.1 200 OK\r\n")?;
+ let attempt = ca... | 2 | 8 | 7 |
57e8aa58b79c4d8ee1b264893e51c1c3685f1342 | Martin Algesten | 2023-12-10T11:59:13 | Refactor error | diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..0b1c8f5
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,69 @@
+use core::str::Utf8Error;
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub enum HootError {
+ /// The borrowed buffer did not have enough space to hold the
+ /// data we attempte... | 4 | 80 | 72 |
fb2b5cc221c6fa59dddb19badb8d767c9f09805b | Martin Algesten | 2023-12-10T11:47:16 | Parse recv headers | diff --git a/src/lib.rs b/src/lib.rs
index 4b8e70a..eecf755 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,7 +15,7 @@ mod vars;
pub use vars::{body, method, state, version};
mod recv;
-pub use recv::Attempt;
+pub use recv::{Attempt, AttemptStatus};
mod parser;
mod send;
@@ -72,6 +72,9 @@ pub enum HootError {
... | 3 | 164 | 62 |
68e43b9b4c9d7c7c57d9b14cb0fffeacf0310fe0 | Martin Algesten | 2023-12-10T10:21:44 | parse status line | diff --git a/src/lib.rs b/src/lib.rs
index e5d64e9..4b8e70a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,19 +1,21 @@
//! no_std, allocation free http library.
// For tests we use std.
-#![cfg_attr(not(test), no_std)]
+// #![cfg_attr(not(test), no_std)]
mod out;
mod util;
mod model;
+use core::str::Utf8Erro... | 6 | 281 | 100 |
4f85e176b07641b2558d0a388162779ee7207da0 | Martin Algesten | 2023-12-09T20:13:09 | Refactor out header parser | diff --git a/src/lib.rs b/src/lib.rs
index 99eea70..2884f5b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,6 +17,7 @@ pub struct Status<'a>(pub u16, pub Option<&'a str>);
mod recv;
pub use recv::ParseResult;
+mod parser;
mod send;
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -80,7 +81,7 @@ mod test {
use s... | 5 | 70 | 21 |
cb9943a51b20a6b783042cf39b5a78aaac31183c | Martin Algesten | 2023-12-09T18:22:46 | chunked send | diff --git a/src/lib.rs b/src/lib.rs
index ef438b8..99eea70 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -55,6 +55,9 @@ pub enum HootError {
/// Header is not allowed for HTTP/1.1
ForbiddenHttp11Header,
+ /// The trailer name is not allowed.
+ ForbiddenTrailer,
+
/// Attempt to send more content t... | 3 | 112 | 12 |
64e9fc5dee3d7893b215cd9bd8ba949ecfe0f82b | Martin Algesten | 2023-12-09T17:50:35 | Send body | diff --git a/src/lib.rs b/src/lib.rs
index e8ed776..ef438b8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -54,6 +54,12 @@ pub enum HootError {
/// Header is not allowed for HTTP/1.1
ForbiddenHttp11Header,
+
+ /// Attempt to send more content than declared in the `Content-Length` header.
+ SentMoreThanCo... | 4 | 90 | 18 |
bd8ba9d363d1aba38353be12c1344cd1709e9931 | Martin Algesten | 2023-12-09T17:18:37 | More tests | diff --git a/src/send.rs b/src/send.rs
index abab0ba..7f17cb9 100644
--- a/src/send.rs
+++ b/src/send.rs
@@ -247,6 +247,35 @@ mod test {
let e = x.unwrap_err();
assert_eq!(e, HootError::HeaderValue);
+ Ok(())
+ }
+ #[test]
+ pub fn test_illegal_body_header() -> Result<()> {
+ ... | 1 | 29 | 0 |
4c9930454615614cc245d0fba60ed66414dc2c7c | Martin Algesten | 2023-12-09T17:15:52 | Forbid host header | diff --git a/src/lib.rs b/src/lib.rs
index 415bdee..e8ed776 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -51,6 +51,9 @@ pub enum HootError {
/// `content-length` and `transfer-encoding` must be set using
/// `with_body()` and `with_body_chunked()`.
ForbiddenBodyHeader,
+
+ /// Header is not allowed for... | 2 | 49 | 36 |
2e92b413545d3157c9c58ff91621fda6eb372079 | Martin Algesten | 2023-12-09T17:12:09 | Host header in HTTP/1.1 | diff --git a/src/out.rs b/src/out.rs
index d4d3ee0..1d22cdb 100644
--- a/src/out.rs
+++ b/src/out.rs
@@ -1,6 +1,6 @@
-use core::fmt::{self, Write};
+use core::fmt;
-use crate::{HootError, Result, OVERFLOW};
+use crate::{HootError, Result};
pub(crate) struct Out<'a> {
buf: &'a mut [u8],
@@ -41,13 +41,6 @@ impl... | 3 | 48 | 39 |
1cd5e6a5288a3006ff21faebd8f9a2d81bfa117b | Martin Algesten | 2023-12-09T16:36:27 | Forbid some headers | diff --git a/src/lib.rs b/src/lib.rs
index 95a5c69..415bdee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -21,10 +21,36 @@ mod send;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum HootError {
+ /// The borrowed buffer did not have enough space to hold the
+ /// data we attempted to write.
+ ///
+ /// C... | 3 | 88 | 7 |
d56cb93228b013150ba7198d7f37da444855915f | Martin Algesten | 2023-12-09T15:44:53 | Body type as var | diff --git a/src/lib.rs b/src/lib.rs
index e61f4d2..95a5c69 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,7 +10,7 @@ mod model;
pub use model::{Call, CallState, Output};
mod vars;
-pub use vars::{method, state, version};
+pub use vars::{body, method, state, version};
#[derive(Debug, Clone, PartialEq, Eq)]
pub... | 6 | 127 | 52 |
99c87b9da6508ea62e6689e080df258c441965aa | Martin Algesten | 2023-12-09T14:55:35 | Validate sent headers | diff --git a/src/lib.rs b/src/lib.rs
index 11d814b..e61f4d2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,7 +19,7 @@ mod recv;
pub use recv::ParseResult;
mod send;
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone, Copy, PartialEq)]
pub enum HootError {
OutputOverflow,
ParseError(httparse::Error),
... | 5 | 137 | 45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.