arduino-libraries / ArduinoHttpClient

Arduino HTTP Client library
288 stars 172 forks source link

Update state on connect #128

Open episource opened 2 years ago

episource commented 2 years ago

HttpClient implements inherited Client::connect(IPAddress ip, uint16_t port) and Client::connect(const char *host, uint16_t port). The existing implementation is to simple: it does not update internal state variables iServerName, iServerAddressand iServerPort, but just invokes the wrapped client. This causes subsequent requests to be incorrect (e.g. wrong host header).

This PR changes connect to also update state.

github-actions[bot] commented 2 years ago

Memory usage change @ 967f1bbfcc79e29fc95faa13927bcde7faf4391f

Board flash % RAM for global variables %
arduino:samd:mkr1000 :small_red_triangle: +24 - +32 +0.01 - +0.01 0 - 0 0.0 - 0.0
Click for full report table Board|examples/BasicAuthGet
flash|%|examples/BasicAuthGet
RAM for global variables|%|examples/CustomHeader
flash|%|examples/CustomHeader
RAM for global variables|%|examples/DweetGet
flash|%|examples/DweetGet
RAM for global variables|%|examples/DweetPost
flash|%|examples/DweetPost
RAM for global variables|%|examples/HueBlink
flash|%|examples/HueBlink
RAM for global variables|%|examples/PostWithHeaders
flash|%|examples/PostWithHeaders
RAM for global variables|%|examples/SimpleDelete
flash|%|examples/SimpleDelete
RAM for global variables|%|examples/SimpleGet
flash|%|examples/SimpleGet
RAM for global variables|%|examples/SimpleHttpExample
flash|%|examples/SimpleHttpExample
RAM for global variables|%|examples/SimplePost
flash|%|examples/SimplePost
RAM for global variables|%|examples/SimplePut
flash|%|examples/SimplePut
RAM for global variables|%|examples/SimpleWebSocket
flash|%|examples/SimpleWebSocket
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- arduino:samd:mkr1000|32|0.01|0|0.0|32|0.01|0|0.0|24|0.01|0|0.0|24|0.01|0|0.0|32|0.01|0|0.0|32|0.01|0|0.0|24|0.01|0|0.0|32|0.01|0|0.0|32|0.01|0|0.0|32|0.01|0|0.0|32|0.01|0|0.0|32|0.01|0|0.0
Click for full report CSV ``` Board,examples/BasicAuthGet
flash,%,examples/BasicAuthGet
RAM for global variables,%,examples/CustomHeader
flash,%,examples/CustomHeader
RAM for global variables,%,examples/DweetGet
flash,%,examples/DweetGet
RAM for global variables,%,examples/DweetPost
flash,%,examples/DweetPost
RAM for global variables,%,examples/HueBlink
flash,%,examples/HueBlink
RAM for global variables,%,examples/PostWithHeaders
flash,%,examples/PostWithHeaders
RAM for global variables,%,examples/SimpleDelete
flash,%,examples/SimpleDelete
RAM for global variables,%,examples/SimpleGet
flash,%,examples/SimpleGet
RAM for global variables,%,examples/SimpleHttpExample
flash,%,examples/SimpleHttpExample
RAM for global variables,%,examples/SimplePost
flash,%,examples/SimplePost
RAM for global variables,%,examples/SimplePut
flash,%,examples/SimplePut
RAM for global variables,%,examples/SimpleWebSocket
flash,%,examples/SimpleWebSocket
RAM for global variables,% arduino:samd:mkr1000,32,0.01,0,0.0,32,0.01,0,0.0,24,0.01,0,0.0,24,0.01,0,0.0,32,0.01,0,0.0,32,0.01,0,0.0,24,0.01,0,0.0,32,0.01,0,0.0,32,0.01,0,0.0,32,0.01,0,0.0,32,0.01,0,0.0,32,0.01,0,0.0 ```
matiasba commented 2 years ago

@per1234 any chance we can merge this pull request? it seems very useful, as the current implementation fails when making multiples request.