Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored HttpClient, HttpServer and WebsocketConnection. #1112

Merged
merged 1 commit into from
May 4, 2017

Conversation

slaff
Copy link
Contributor

@slaff slaff commented May 2, 2017

  • Better Code Design (There were some places that deserved to be called "big-ball-of-mud" ).
  • Faster and powerful HttpParser used in both HttpClient and HttpServer.
  • Support for pipelining in both HttpClient and HttpServer.
  • Support for connection reuse for both HttpClient and HttpServer.
  • SSL session resumption support for HttpClient and HttpServer.
  • Added ResourceTree to HttpServer to allow more flexible definition of resources.
  • Added streaming support to both Http and WebSocket processing.
  • rBootHttpUpdate should stop now on failure as early as possible.
  • Changed the ContentType code to allow easier definition of new mime types.

Backwards-Incompatible changes

  • WebSocket is renamed to WebSocketConnection to reflect better its meaning and intended use.
  • Removed the tightly coupled websocket methods inside the HttpServer. You can use WebSocketResource and add it to the HttpServer resource tree to achieve the same results.
  • Moved writeInit(), writeFlash(const u8 *data, u16 size) and writeEnd() methods from rBootHttpUpdate to rBootItemOutputStream.
  • TemplateFileStream::setVarsFromRequest needs to be refactored completely. The current code couples TemplateFileStream to HttpRequest, which is too restrictive. TemplateFileStream::setVars method should be introduced that accepts HashMap<String,String>
  • HttpRequest::getRequestMethod() is removed. Use HttpRequest::method instead.
  • CommandExecutor with WebsocketConnection won't work.

- Better Code Design
- Faster and powerful HttpParser used in both HttpClient and Server
- Support for pipelinging in both HttpClient and HttpServer
- Suppot for connection reusage for both HttpClient and HttpServer
- SSL session resumption support for HttpClient and HttpServer
- Added ResourceTree to the HttpServer to allow more flexible definition of resources
- Added streaming support to both Http and WebSocket processing.
- rBootHttpUpdate should fail now as early as possible.
- Changed the ContentType code to allow easier definition of new mime types.
@Vity01
Copy link

Vity01 commented Jun 15, 2017

God bless the guy (@slaff) who rewrote the HttpClient. 👍
It was the weakest part of the Sming. I can't wait for 3.3.0.

@Vity01
Copy link

Vity01 commented Jun 15, 2017

@slaff Do you close/clean/free input stream for body in HttpRequest somewhere or the caller is responsible?

@slaff
Copy link
Contributor Author

slaff commented Jun 16, 2017

@Vity01 If you use the HttpClient then at the end of an HTTP request the request data is freed in HttpConnection::staticOnMessageComplete and similar thing is happening for the HttpServer in HttpServerConnection::staticOnMessageComplete.

@slaff slaff removed the 3 - Review label Jun 16, 2017
@Vity01
Copy link

Vity01 commented Jun 16, 2017

@slaff thanks for the info, maybe the line comment might be helpful also for other developers
Thanks again for the great job.

@lucas-bremond
Copy link

Great job!

Just out of curiosity, what is the rationale behind:

aRequest.getRequestMethod() == RequestMethod::GET

being changed into:

aRequest.method == HTTP_GET

?

It's shorter indeed, but seems more brittle to me.
Was it performance driven?

@slaff slaff deleted the feature/refactored-http branch July 22, 2019 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants