Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http patch: export and use SERVER header #442

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion http/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
time::{Instant, SystemTime},
};

const SERVER: &str = concat!("trillium/", env!("CARGO_PKG_VERSION"));
/// Default Server header
pub const SERVER: &str = concat!("trillium/", env!("CARGO_PKG_VERSION"));

/** A http connection

Expand Down Expand Up @@ -380,7 +381,7 @@
self.request_content_length().ok().flatten(),
&mut self.buffer,
&mut self.transport,
&mut self.request_body_state,

Check warning on line 384 in http/src/conn.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> http/src/conn.rs:384:13 | 384 | &mut self.request_body_state, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.request_body_state` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default
None,
encoding(&self.request_headers),
&self.http_config,
Expand All @@ -388,7 +389,7 @@
}

/**
returns the [encoding_rs::Encoding] for this request, as

Check warning on line 392 in http/src/conn.rs

View workflow job for this annotation

GitHub Actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks --> http/src/conn.rs:392:18 | 392 | returns the [encoding_rs::Encoding] for this request, as | ^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown note: the lint level is defined here --> http/src/lib.rs:10:23 | 10 | #![warn(missing_docs, clippy::pedantic, clippy::perf, clippy::cargo)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(clippy::doc_markdown)]` implied by `#[warn(clippy::pedantic)]` help: try | 392 | returns the [`encoding_rs::Encoding`] for this request, as | ~~~~~~~~~~~~~~~~~~~~~~~
determined from the mime-type charset, if available

```
Expand All @@ -404,7 +405,7 @@
}

/**
returns the [encoding_rs::Encoding] for this response, as

Check warning on line 408 in http/src/conn.rs

View workflow job for this annotation

GitHub Actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks --> http/src/conn.rs:408:18 | 408 | returns the [encoding_rs::Encoding] for this response, as | ^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 408 | returns the [`encoding_rs::Encoding`] for this response, as | ~~~~~~~~~~~~~~~~~~~~~~~
determined from the mime-type charset, if available

```
Expand All @@ -420,9 +421,9 @@
}

/**
returns a [ReceivedBody] that references this conn. the conn

Check warning on line 424 in http/src/conn.rs

View workflow job for this annotation

GitHub Actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks --> http/src/conn.rs:424:16 | 424 | returns a [ReceivedBody] that references this conn. the conn | ^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 424 | returns a [`ReceivedBody`] that references this conn. the conn | ~~~~~~~~~~~~~~
retains all data and holds the singular transport, but the
ReceivedBody provides an interface to read body content

Check warning on line 426 in http/src/conn.rs

View workflow job for this annotation

GitHub Actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks --> http/src/conn.rs:426:5 | 426 | ReceivedBody provides an interface to read body content | ^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 426 | `ReceivedBody` provides an interface to read body content | ~~~~~~~~~~~~~~
```
# async_io::block_on(async {
# use trillium_http::{Conn, Method};
Expand Down Expand Up @@ -644,7 +645,7 @@
and should be computationally lightweight. If your _application_
needs additional async processing, use your runtime's task spawn
within this hook. If your _library_ needs additional async
processing in an after_send hook, please open an issue. This hook

Check warning on line 648 in http/src/conn.rs

View workflow job for this annotation

GitHub Actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks --> http/src/conn.rs:648:22 | 648 | processing in an after_send hook, please open an issue. This hook | ^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 648 | processing in an `after_send` hook, please open an issue. This hook | ~~~~~~~~~~~~
is currently designed for simple instrumentation and logging, and
should be thought of as equivalent to a Drop hook.
*/
Expand Down
2 changes: 1 addition & 1 deletion http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod error;
pub use error::{Error, Result};

mod conn;
pub use conn::Conn;
pub use conn::{Conn, SERVER};

mod connection_status;
pub use connection_status::ConnectionStatus;
Expand Down
6 changes: 3 additions & 3 deletions http/tests/one_hundred_continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use indoc::{formatdoc, indoc};
use pretty_assertions::assert_eq;
use stopper::Stopper;
use test_harness::test;
use trillium_http::{Conn, KnownHeaderName};
use trillium_http::{Conn, KnownHeaderName, SERVER};
use trillium_testing::{harness, TestResult, TestTransport};

const TEST_DATE: &'static str = "Tue, 21 Nov 2023 21:27:21 GMT";
Expand Down Expand Up @@ -43,7 +43,7 @@ async fn one_hundred_continue() -> TestResult {

let expected_response = formatdoc! {"
HTTP/1.1 200 OK\r
Server: trillium/0.3.5\r
Server: {SERVER}\r
Date: {TEST_DATE}\r
Connection: close\r
Content-Length: 20\r
Expand Down Expand Up @@ -76,7 +76,7 @@ async fn one_hundred_continue_http_one_dot_zero() -> TestResult {

let expected_response = formatdoc! {"
HTTP/1.0 200 OK\r
Server: trillium/0.3.5\r
Server: {SERVER}\r
Date: {TEST_DATE}\r
Connection: close\r
Content-Length: 20\r
Expand Down
Loading