You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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 HTTPSServerand 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.
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.
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!
Great work! Thank you. I'll go with your version of course. I just have to
make minor changes in my project to adjust to it.
V V ned., 2. sep. 2018 ob 03:15 je oseba Frank Hessel <
notifications@github.com> napisala:
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 HTTP*S* 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!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AouyrRKeA9vqpZgMndD7aQMx3u57JSE1ks5uWzE9gaJpZM4WWPkB>
.
Frank, I have problems compiling new code with Arduino. Beginning with:
HTTPConnection.cpp:449: error: macro "bind" passed 4 arguments, but takes
just 3
next = std::function<void()>(std::bind((*itMw), &req, &res, next));
Any idea how to solve this?
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.
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.
I use Windows 10. I'll install Arduino and ESP tools again from the scratch
and try again ...
V V ned., 2. sep. 2018 ob 16:09 je oseba Frank Hessel <
notifications@github.com> napisala:
Activity
fhessel commentedon Sep 1, 2018
I had this in mind when creating the code, so the whole SSL stuff should mainly be done in the
HTTPSServerandHTTPSConnectionclass – note that many other classes just start withHTTPsomethingand 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 theHTTPSConnectionclass 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 anHTTPServerandHTTPConnectionthat both sit on top of that new class. Creating an instance ofHTTPSServerand one ofHTTPServerwith the sameResourceNodes 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.
BojanJurca commentedon Sep 1, 2018
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.
BojanJurca commentedon Sep 1, 2018
... exept for refactoring and new classes. Le me upload the code and then you can decide whether to keep it or not.
fhessel commentedon Sep 1, 2018
Thank you for the pull request! I'll have a look at it and see how I can integrate it.
fhessel commentedon Sep 2, 2018
I did some refactoring, so now you have an
HTTPServerclass as well as anHTTPSServerclass. You can either use one of them to serve just one protocol or create two instances and run them in parallel (seehttps_server.cppfor 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!
BojanJurca commentedon Sep 2, 2018
BojanJurca commentedon Sep 2, 2018
fhessel commentedon Sep 2, 2018
That line is for a change I made for #10. The
bindin that line should be expanded to thebinddeclared 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.
fhessel commentedon Sep 2, 2018
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
c5d8a1e28cfor now.BojanJurca commentedon Sep 2, 2018
BojanJurca commentedon Sep 2, 2018