esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
16.08k stars 13.33k forks source link

Added support to override host header. #9092

Open nilo85 opened 9 months ago

nilo85 commented 9 months ago

As dns is not working on my network I decided to workaround the issue for now and figured this might actually be a feature we want here =)

nilo85 commented 9 months ago

I no longer need this hack, however, there might be situations you need to override host header (proxy use etc) so might still make sense to support

mcspr commented 8 months ago

Perhaps the client should allow addHeader to override Host:? Meaning, when headers are prepared it would check whether it was added or not; and if not, use the default _host. Right now it is restricted, don't see why it should be tbh

nilo85 commented 8 months ago

@mcspr I suppose, however to be completely http compliant, you can pass multiple values for same header, most other http implementations do setHeader and addHeader, where setHeader sets a single header and replaces whatever would have been there before, and addHeader would send multiple values.

However in this case, judging by the code I suspect the restriction here is to kep the code simple as the host header is hardcoded in the request call.

I would be fine rejecting this PR as I no longer need it, but possible it could make sense to consider adopting more http client features in the future, if needed... I suspect for most applications using these microchips, explicit proxy settings etc is overkill so I personally would consider it a corner case