DaKaZ / esp8266-restclient

Arduino RESTful HTTP Request Library
MIT License
124 stars 26 forks source link

Fixes for PUT #2

Closed mikaelgu80 closed 7 years ago

mikaelgu80 commented 7 years ago

Changes made based on tests run against OpenHAB rest API. I've only tried GET and PUT and haven't validated against any other services. Can't seem to get DHCP working...

DaKaZ commented 7 years ago

Looks good, thanks!

dbudwin commented 7 years ago

This merge breaks being able to POST over SSL, I haven't tested POST'ing over non-SSL, or other verbs like GET. If I check out the commit before this merge commit, things work fine. I turned on debug mode and below is my slightly redacted output. I would have created an issue, but there is no issues tab for this repo:

HTTP: connect
Verifiying SSL certificate
SSL certificate matches
HTTP: connected
REQUEST: 

SSL Print: POST /api/devices/info HTTP/1.1
Host: robohome.xyz:443
Connection: close
Content-Length: 74
Content-Type: application/x-www-form-urlencoded
userId=<redacted>&action=turnon&deviceId=<redacted>

END REQUEST
HTTP: call readResponse
HTTP: NON-NULL RESPONSE POINTER: 
HTTP: RESPONSE: 
HTTP: Connect: 1 Available: 0
.........<about 700,000 more dots>.........HTTPS client closed 
HTTP: return readResponse3
HTTP: return readResponse
HTTP: stop client
HTTP: client stopped

Any idea what's going on? Looking at the this commit I wonder if @mikaelgu80 meant to say if (contentType == NULL) instead of if (contentType != NULL. If it should be != I would suggest removing the // default comment since it doesn't happen by default anymore.

Thanks!

DaKaZ commented 7 years ago

@mikaelgu80 I just enabled "issues" - sorry about that. You definitely found a bug (which I just patched) but I don think that should have caused your problems unless your server is expecting a certain type of post data and never returning. If you do open up an issue, please post the code you are using to create your rest client and issue the post. Thanks