Specify User-Agent on every HTTP request (#3628)#3682
Specify User-Agent on every HTTP request (#3628)#3682mgsloan merged 1 commit intocommercialhaskell:masterfrom
Conversation
Fix: commercialhaskell#3628 Wrap up functions in `Network.HTTP.Client` and `Network.HTTP.Simple` to add User-Agent to the request object.
|
This looks like a solid approach to me! Perhaps, to help avoiding using the not wrapped function, we can use a similar HLint trick like in https://github.com/commercialhaskell/stack/blob/master/.hlint.yaml#L44 - where a warning is produced (and the CI will fail) if the wrong function is used - assuming we always want these headers to go out? I assume so! Thanks for the patch! |
|
@lwm Thanks for advice!
You mean, should I rename functions exported by If I should rename, I'm going to prefix |
|
I'm not exactly sure either ;) I thought you could pass full import paths (like over here) and get away with it. If you can't do that, maybe the renaming with the prefix is a better option in general - less magic! |
|
Good stuff @igrep , thanks a bunch! Cool idea bout using hlint to reduce likelihood of regressions, @lwm! Indeed I'm not sure if HLint can distinguish where identifiers are imported from. Seems like it'd be a major weakness if not, I'm guessing it can do this. I've opened #3700 to track implementing the idea. |
Fix: #3628
Wrap up functions in
Network.HTTP.ClientandNetwork.HTTP.Simpletoadd User-Agent to the request object.
Testing the change
I confirmed some requests are fixed by
stack setup,stack install,stack new.But I haven't tested all HTTP requests made by
stack.For reviewers
I'm not sure especially with the name and place of the wrapper module (and the name of its functions).
Feel free to modify for better module structure.