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

Add support for 'Expect: 100-continue' in HTTP server. #1931

Merged
merged 1 commit into from
Nov 7, 2019

Conversation

aemseemann
Copy link
Contributor

When uploading files as multipart/form-data, browsers (and other HTTP clients like curl) may generate an Expect: 100-continue header (depending on file size) and subsequently wait for a 100 Continue response from the server before continuing to send the body data.

Although most clients will continue to send the body data anyway after a short timeout, this PR avoids the timeout.

@slaff
Copy link
Contributor

slaff commented Nov 6, 2019

@aemseemann Did you test your PR?

int endPos = contentType.indexOf(';');
if(endPos != -1) {
contentType = contentType.substring(0, endPos);
if(!error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aemseemann Refactor this block and try to avoid many levels of nested ifs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also prefer to see if (endPos >= 0) as its more robust

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Hope that it's ok to skip all the body parser setup in case error != 0. Although this change is not strictly necessary for this PR, it seemed futile to prepare for a body that will never come.

@aemseemann
Copy link
Contributor Author

@slaff: I did test this patch successfully on top of #1817 with a command line like curl -F firmware=@$(RBOOT_ROM_0_BIN).signed http://$(BOARD_URL)/upload.
I also verified the Expect:... / 100 Continue exchange with Wireshark and that the body transmission continues immediately. Without this patch, Wireshark timestamps show a delay between headers and body of approximately 1 second. This isn't much, but still avoidable by simply answering to the Expect header.

@slaff slaff added this to the 4.0.1 milestone Nov 7, 2019
@slaff slaff removed the 3 - Review label Nov 7, 2019
@slaff slaff merged commit b722be8 into SmingHub:develop Nov 7, 2019
@slaff
Copy link
Contributor

slaff commented Nov 7, 2019

@aemseemann I don't remember if I have mentioned this: Thanks again for your contribution(s) and welcome to the Sming team :)

@aemseemann aemseemann deleted the feature/expect-100-continue branch November 8, 2019 19:34
@slaff slaff mentioned this pull request Jan 2, 2020
4 tasks
slaff pushed a commit to slaff/Sming that referenced this pull request Feb 6, 2020
New features
------------------
- No-WiFi build option SmingHub#2004 - get more resources if your application is not using WIFI.
- Multiple SSL adapters based on axTLS and BearSSL.  SmingHub#1999
- Added basic Crypto support library SmingHub#2014
- Updates framework to build using GCC 9.2.0 toolchain for C++17. SmingHub#1825
- Modbus master SmingHub#1992
- Implemented Small String Optimisation (SSO). SmingHub#1951
- Webcam stream and sample webcam web server. SmingHub#1981
- Allow HTTP connections to ignore rejected body content SmingHub#1928

Improvements
-------------------
- Some improvements to multipart parser SmingHub#2007
- Update ArduinoJson to 6.13.0 SmingHub#1979
- Added precaching from Arduino for ESP8266. SmingHub#1965
- Add support for 'Expect: 100-continue' in HTTP server. SmingHub#1931
- Upgrade to FlashString Library  SmingHub#1974, SmingHub#2013

Bug fixes
-------------
- Updated mqtt-codec to allow publish messages without payload. SmingHub#1976
- HttpConnection freed twice. SmingHub#1938
- Hangs at startup when custom heap enabled. SmingHub#1996
- Fix issues reported by valgrind SmingHub#2017

Breaking changes and Migration
-------------------------------------------
- See our [dedicated page](https://sming.readthedocs.io/en/latest/upgrading/4.0-4.1.html) for migration from 4.0.0 to 4.1.0.

All PRs scheduled for this release can be seen from [here](https://github.com/SmingHub/Sming/milestone/23)
slaff pushed a commit to slaff/Sming that referenced this pull request Feb 6, 2020
New features
------------------
- No-WiFi build option SmingHub#2004 - get more resources if your application is not using WIFI.
- Multiple SSL adapters based on axTLS and BearSSL.  SmingHub#1999
- Added basic Crypto support library SmingHub#2014
- Updates framework to build using GCC 9.2.0 toolchain for C++17. SmingHub#1825
- Modbus master SmingHub#1992
- Implemented Small String Optimisation (SSO). SmingHub#1951
- Webcam stream and sample webcam web server. SmingHub#1981
- Allow HTTP connections to ignore rejected body content SmingHub#1928

Improvements
-------------------
- Some improvements to multipart parser SmingHub#2007
- Update ArduinoJson to 6.13.0 SmingHub#1979
- Added precaching from Arduino for ESP8266. SmingHub#1965
- Add support for 'Expect: 100-continue' in HTTP server. SmingHub#1931
- Upgrade to FlashString Library  SmingHub#1974, SmingHub#2013

Bug fixes
-------------
- Updated mqtt-codec to allow publish messages without payload. SmingHub#1976
- HttpConnection freed twice. SmingHub#1938
- Hangs at startup when custom heap enabled. SmingHub#1996
- Fix issues reported by valgrind SmingHub#2017

Breaking changes and Migration
-------------------------------------------
- See our [dedicated page](https://sming.readthedocs.io/en/latest/upgrading/4.0-4.1.html) for migration from 4.0.0 to 4.1.0.

All PRs scheduled for this release can be seen from [here](https://github.com/SmingHub/Sming/milestone/23)
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.

None yet

3 participants