Skip to content

HTTP support #17

Closed
Closed

Description

@BojanJurca

Hello! I just finished adding (unencrypted) HTTP functionality for my home project. I need this because it works much faster than HTTPS when I connect to the ESP from my home WiFi. Although it will be difficult to keep up with your upgrades in the future. I would like to suggest that you include HTTP in your project, if it does not ruin your concept?

Activity

  1. fhessel commented on Sep 1, 2018

    @fhessel
    Owner

    I had this in mind when creating the code, so the whole SSL stuff should mainly be done in the HTTPSServer and HTTPSConnection class – note that many other classes just start with HTTPsomething and should be generic for both protocols. However, parsing the request line and header is not really separated from the SSL connection handling by now, but this can be done by refactoring the HTTPSConnection class so that it does no more than handling the actual SSL stuff and putting everything else in a new class. That would allow to implement an HTTPServer and HTTPConnection that both sit on top of that new class. Creating an instance of HTTPSServer and one of HTTPServer with the same ResourceNodes being configured should then allow you to handle both protocols.
    However, that's not at prio 1 for me, as there are HTTP available for the ESP32 and solving some other issues is more urgent for some personal projects I'm working on at the moment.

  2. BojanJurca commented on Sep 1, 2018

    @BojanJurca
    ContributorAuthor

    This is exactly what I have done. I introduced additional listening socket in HTTPSServer. Everything else is the same except for minor changes in some functions that read from and write to SSL - they now read directly from and write directly to socket and this is it. All your HTTPS functionalities work under HTTP as well.

  3. BojanJurca commented on Sep 1, 2018

    @BojanJurca
    ContributorAuthor

    ... exept for refactoring and new classes. Le me upload the code and then you can decide whether to keep it or not.

  4. fhessel commented on Sep 1, 2018

    @fhessel
    Owner

    Thank you for the pull request! I'll have a look at it and see how I can integrate it.

  5. fhessel commented on Sep 2, 2018

    @fhessel
    Owner

    I did some refactoring, so now you have an HTTPServer class as well as an HTTPSServer class. You can either use one of them to serve just one protocol or create two instances and run them in parallel (see https_server.cpp for an example).

    My main focus for the refactoring was to have an additional abstraction layer between handling HTTP, so the HTTPS classes now only do the stuff that's specific for TLS. I hope that's also a suitable solution for your project. Thank you again for providing the code!

  6. BojanJurca commented on Sep 2, 2018

    @BojanJurca
    ContributorAuthor
  7. BojanJurca commented on Sep 2, 2018

    @BojanJurca
    ContributorAuthor
  8. fhessel commented on Sep 2, 2018

    @fhessel
    Owner

    That line is for a change I made for #10. The bind in that line should be expanded to the bind declared in the functional header of the standard library, but your compiler seems to go for the socket one (which requires exactly three parameters, not one or more). At least that's how I would interpret that error.

    I'll setup a small Arduino project to be able to reproduce it and then try to organize the includes in a non-conflicting way.

  9. fhessel commented on Sep 2, 2018

    @fhessel
    Owner

    I can build the project without any problems in the Arduino IDE.

    Could you provide me with some additional info? I think being able to reproduce your problem will make it easier to find its cause, rather than randomly changing some includes and let you try again and again.
    Did you use the latest version of arduino-esp32? Which OS do you use? Which version of the Arduino IDE?

    If you just want to have HTTP/HTTPS in parallel, without the middleware feature, you can work with commit c5d8a1e28c for now.

  10. BojanJurca commented on Sep 2, 2018

    @BojanJurca
    ContributorAuthor
  11. BojanJurca commented on Sep 2, 2018

    @BojanJurca
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions