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

Hijack connection through http.ResponseController in http upgrader #181

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

xakep666
Copy link
Contributor

@xakep666 xakep666 commented Aug 9, 2023

Go 1.20 introduced new and more convenient way to control response and discover features - ResponseController. It's methods can introspect middlewares implementing following interface

type rwUnwrapper interface {
	Unwrap() ResponseWriter
}

source

This PR contains changes to use it if go version newer than 1.20. Old behaviour will be used if go version is older than 1.20.

Copy link
Collaborator

@cristaloleg cristaloleg left a comment

Choose a reason for hiding this comment

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

Nice one. Can you drop the newline before return in both hijack functions please?

@xakep666
Copy link
Contributor Author

xakep666 commented Aug 9, 2023

@cristaloleg done

@cristaloleg cristaloleg merged commit fe40e5d into gobwas:master Aug 9, 2023
9 checks passed
@cristaloleg
Copy link
Collaborator

Thanks @xakep666 I will tag 1.3.0 a bit later today.

@xakep666 xakep666 deleted the use-response-controller branch August 9, 2023 20:14
@cristaloleg
Copy link
Collaborator

@jvilhuber
Copy link

Note go 1.21 is out, so the test "!go1.20" for go 1.19 is no longer correct.

@xakep666
Copy link
Contributor Author

xakep666 commented Aug 17, 2023

@jvilhuber "go 1.20", means "go 1.20 or newer" so negated one is "go 1.19 or older"

@jvilhuber
Copy link

Thanks! Learned something new today!

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.

3 participants