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

Upgrade to hyper 1.0.0 #7

Closed
wants to merge 9 commits into from

Conversation

howardjohn
Copy link
Contributor

@howardjohn howardjohn commented Nov 15, 2023

Update to hyper 1.0.0.

This change is non trivial due to the bumping of http. To handle this, this PR introduces conversion functions for http0.2<->http1.0.

TODO:

  • Remove unsafe -- I don't think there are any issues here, just did it to be quick; will fix up tomorrow hopefully
  • Add more documentation
  • Fix tests, maybe? I had issues running these from main, not sure if they are broken or its an issue on my side

cc @davidpdrsn @LucioFranco

src/body.rs Outdated
Comment on lines 174 to 176
unsafe {
std::mem::transmute::<http_1::HeaderMap, http_02::HeaderMap>(h)
}
Copy link
Owner

Choose a reason for hiding this comment

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

Yeah we can't have any transmutes here 😅 Just have to convert one type into the other by copying the data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this was originally just a temporary hack. However, I am struggling to actually remove it. I pushed up a commit which kind of works, but its fairly terrible. Most notably the extension part of Request/Response doesn't actually seem convertable, unless I am missing some way.

The rest did work though, although the conversion is pretty terrible. Likely can use some improvements there, I don't think its robust/correct.

I pushed up another commit with these changes to iterate on

Copy link
Owner

@davidpdrsn davidpdrsn Nov 16, 2023

Choose a reason for hiding this comment

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

However, I am struggling to actually remove it.

It might compile but I really doubt it actually works. The memory layout for Extensions for example has changed since it now requires Clone. That'll most likely cause nasty UB.

Most notably the extension part of Request/Response doesn't actually seem convertable, unless I am missing some way

I don't think there is a way to convert extensions since you cannot iterate all the values :/ I'm not sure there is much we can do about it so we have to do some testing and see how much that breaks. I'm pretty sure its gonna break web sockets because they rely on the OnUpgrade extension which is set by hyper and would thus be removed when converting to http 0.2 extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think is the path forward here?

Seems like our options are:

  1. transmute - unsafe and almost certainly broken. Definitely don't like this approach
  2. Convert what we can - should work for some cases but break others
  3. Change http directly (possibly in both versions?) to expose things we need
  4. Do nothing; wait for rest of ecosystem to catch up to hyper 1.0

Not sure about others but I am personally only using this for tonic. (2) seems viable enough for that use case (although it wasn't extensively tested yet). (4) also might be fine as well, assuming tonic adds hyper 1.0 support in the coming weeks/months.

Copy link
Owner

Choose a reason for hiding this comment

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

I think we should go with 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I took a stab at it. Not great but best I could come up with. Can probably improve a bit, but for Extension we would need changes to http

src/lib.rs Outdated Show resolved Hide resolved
@howardjohn howardjohn marked this pull request as ready for review November 28, 2023 21:31
@howardjohn
Copy link
Contributor Author

@davidpdrsn I think this is ready to go now, LMK what you think.

@howardjohn
Copy link
Contributor Author

Since tonic now supports hyper 1.0 directly, I don't personally have a need for this. If anyone its interested in taking it over please feel free. Thanks!

@howardjohn howardjohn closed this Jul 8, 2024
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