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

various fixes needed to integrate into surf + tide #44

Merged
merged 19 commits into from
Jan 13, 2020

Conversation

dignifiedquire
Copy link
Member

@dignifiedquire dignifiedquire commented Dec 29, 2019

  • handle content length on the body
  • correctly detect chunked encoding
  • error out on transfer-encoding + content-length
  • decode chunked encoding

With the list of these fun repos I made surf + tide work with async-h1

@dignifiedquire dignifiedquire changed the title fix: only read Content-Length length [wip] fix: only read Content-Length length Dec 29, 2019
@dignifiedquire dignifiedquire changed the title [wip] fix: only read Content-Length length various fixes needed to integrate into surf + tide Dec 30, 2019
Copy link
Collaborator

@rylev rylev left a comment

Choose a reason for hiding this comment

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

I haven't gone through the decoding part super thoroughly. It's a bit difficult to understand and seems to be a bit magical. Is there any way to simplify or make the steps more obvious?

src/client.rs Show resolved Hide resolved
@@ -1,18 +1,19 @@
//! Process HTTP connections on the client.

use async_std::io::{self, BufReader};
use async_std::io::{self, BufReader, Read};
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice actually if we could remove our dependency on async-std and only rely on futures-rs. I don't think this is currently possible because we rely on a timer, but it would be nice to not move away from that direction.

Copy link
Member

Choose a reason for hiding this comment

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

@rylev we're going to need to use channels either way, so we'll have to depend on async-std. And you're right that since we depend on timers we have a dependency either way. I guess the one upside to this though is that it'll work with any runtime out of the box, even if there might be multiple executors running.

src/lib.rs Outdated Show resolved Hide resolved
src/server.rs Show resolved Hide resolved

#[async_std::test]
async fn test_basic_request() {
let case = TestCase::new("fixtures/request1.txt", "fixtures/response1.txt").await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should rename these files to: basic-request.txt and basic-response.txt

src/chunked.rs Show resolved Hide resolved
src/chunked.rs Outdated Show resolved Hide resolved
src/chunked.rs Show resolved Hide resolved
src/chunked.rs Outdated Show resolved Hide resolved
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.

Overall this is looking really good; a few minor nits but nothing critical. Especially the addition of thorough tests inspires confidence.

Thanks so much @dignifiedquire; this is excellent!

src/chunked.rs Show resolved Hide resolved
src/chunked.rs Show resolved Hide resolved
src/chunked.rs Outdated Show resolved Hide resolved
src/chunked.rs Show resolved Hide resolved
);
});
}
}
Copy link
Member

Choose a reason for hiding this comment

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

All put together this file feels pretty long. Is there perhaps a chance we could split it up into a few smaller parts?

Also as @rylev pointed out there are several instances of mem::replace that could probably be replaced by reassigning instead?

src/client.rs Show resolved Hide resolved
src/client.rs Show resolved Hide resolved
src/error.rs Show resolved Hide resolved
src/chunked.rs Outdated Show resolved Hide resolved
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 is a pretty large change; it feels like most of the issues have been addressed, and we should be good enough to merge. Excited for this!

@yoshuawuyts yoshuawuyts merged commit d127c31 into master Jan 13, 2020
@delete-merged-branch delete-merged-branch bot deleted the fix/content-length branch January 13, 2020 23:30
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.

4 participants