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

Optional http/1.0 support #170

Merged
merged 1 commit into from
Dec 26, 2020
Merged

Optional http/1.0 support #170

merged 1 commit into from
Dec 26, 2020

Conversation

jbr
Copy link
Member

@jbr jbr commented Dec 19, 2020

this pr adds support for http/1.0, enabled by the accept_with_opts api caller providing a default host in ServerOptions. http frameworks like tide could surface this as a configuration option to the end user

There may be further work that needs to be done in order to completely support 1.0, but this addresses the biggest blocker and enables us to explore which of the other differences need to be handled at the async-h1 layer

Useful Reference: http://www.ra.ethz.ch/cdstore/www8/data/2136/pdf/pd1.pdf

closes #152
closes #122

@jbr jbr force-pushed the optional-1.0-support branch from 1cc1a42 to d35dacc Compare December 19, 2020 02:54
@jbr jbr added this to the v3 milestone Dec 20, 2020
Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

Comment on lines +49 to +52
pub fn with_default_host(mut self, default_host: &str) -> Self {
self.default_host = Some(default_host.into());
self
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: I'm increasingly convinced that async-h1 could be nicer to use if we had concrete Client and Server structs, and not the intermediate short-hand constructors. Rather than using a separate Options struct, exposing the host param through the constructor may be easier:

let mut server = Server::new();
assert_eq!(server.host(), None);

let mut server = Server::with_host("website.com");
assert_eq!(server.host(), Some("website.com"));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entirely agreed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's been my intent for a few PRs — I've been leaving the functions around until the interface for the structs feels right. My hunch is that implementing future for the struct will simplify a bunch of things

Comment on lines +39 to +45
/// Sets the default http 1.0 host for this server. If no host
/// header is provided on an http/1.0 request, this host will be
/// used to construct the Request Url.
///
/// If this is not provided, the server will respond to all
/// http/1.0 requests with status `505 http version not
/// supported`, whether or not a host header is provided.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 -- I really like how this works! This can very naturally translate to a CLI flag which sets the default URL, or a config which mandates the hostname is set. This feels exactly right.

@jbr jbr merged commit 3e88655 into v3 Dec 26, 2020
@delete-merged-branch delete-merged-branch bot deleted the optional-1.0-support branch December 26, 2020 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants