boblemaire / asyncHTTPrequest

asynchronous HTTP for ESP using ESPasyncTCP. Works like XMLHTTPrequest in JS.
GNU General Public License v3.0
64 stars 31 forks source link

Feature request: make readyStates public #39

Closed woutput closed 3 years ago

woutput commented 3 years ago

Hi and thanks for sharing this library.

Wouldn't it be better if we (users of this library) could use

void some_callback(void* optParm, asyncHTTPrequest* request, int readyState)
{
    if(readyState == readyStateDone)
    {

instead of

void some_callback(void* optParm, asyncHTTPrequest* request, int readyState)
{
    if(readyState == 4)
    {

Currently (v.1.2.2) I see this in asyncHTTPrequest.h:

  private:
...
    enum    readyStates {
                readyStateUnsent = 0,           // Client created, open not yet called
                readyStateOpened =  1,          // open() has been called, connected
                readyStateHdrsRecvd = 2,        // send() called, response headers available
                readyStateLoading = 3,          // receiving, partial data available
                readyStateDone = 4} _readyState; // Request complete, all data available.

Maybe moving this enum definition to the public: part would already solve this feature request?

Thank you, Kind regards, woutput

boblemaire commented 3 years ago

These states are pretty much standard with javascript requests. I would just want to modify them to be less generic and unambiguously unique to this class, to avoid any conflicts. So I'm going to close this and leave the door open for a PR with unique names.