-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Change HTTP::Request#remote_address
type to Socket::Address?
#9210
Change HTTP::Request#remote_address
type to Socket::Address?
#9210
Conversation
I implemented it as a string because in Go it's a string. I'm sure there must be a good reason why the chose String. Why do you need the address? |
In this case for logging just the IP. The port changes on every request and is not useful at all for 99.99% of the cases. Other useful cases are auditing, filtering, geolocation of clients, stats. All these cases need just the IP address without the port. |
Can you split the string by I think this PR might be fine, but I'd like to know why Go chose to use a String. |
I believe a string is just more flexible.
In light of that we might perhaps consider only storing the IP address in |
Go is not the only language out there 🙂
|
Of course. What's more flexible than a string? But we don't put strings everywhere for that reason. And the address can be easily converted to a string. |
Of course I can parse the value, but first it has to be matched with a regex in case is not an In the future, if we find another possibility for |
FYI, I just tested the performance of |
Cool! If other languages provide a non-string value then this change is perfect 💯 |
f32bd60
to
6be86e8
Compare
Co-authored-by: Johannes Müller <johannes.mueller@smj-fulda.org>
I just disabled some specs in win32, mostly for HTTP. I'm confused about the |
Disabling that many specs which worked before this PR is not a good idea. We can just make |
Ok, I’ll try that |
@straight-shoota the specs in win32 are back. I left |
Why Public APIs should not have different types depending on the platform. |
I put I mean, I don't expect the APIs to be different once it's working on Windows. |
This is a breaking change, but probably with a very low impact.
Currently the
remote_address
is aString
with the format "ip:port", so if just the IP is needed extra parsing must be done. Also, this is consistent with other occurrences oflocal_address
andremote_address
in the std.