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

Improved handling of 100 Continue #12113

Merged

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Jul 31, 2024

  • Now HttpClient removed the Expect header if there is no request content.
  • Changed AbstractProxyServlet and ProxyHandler check for request content: now the Content-Type header is not taken into consideration.
  • Now the server avoids sending the 100 Continue response if there is no request content.

sbordet added 2 commits July 30, 2024 19:05
* Changed ContentSender demand from iterate()+IDLE to succeeded()+SCHEDULED.
  This ensures that there is no re-iteration in case a 100 Continue response arrives.
  This, in turn, avoids that the demand is performed multiple times, causing ISE to be thrown.
* Changed the 100 Continue action of the proxy Servlet/Handler, that provides the request content, to be executed by the HttpSender, rather than by the HttpReceiver.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Now `HttpClient` removed the `Expect` header if there is no request content.
* Changed AbstractProxyServlet and ProxyHandler check for request content: now the Content-Type header is not taken into consideration.
* Now the server avoids sending the 100 Continue response if there is no request content.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@joakime
Copy link
Contributor

joakime commented Aug 1, 2024

Is the work here going to help the old 100-Continue issue with AsyncMiddleManServlet?

Now the request body is not defaulted if missing, but just kept null.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@gregw gregw dismissed their stale review August 2, 2024 05:50

I'm OK with the ==0 check

gregw
gregw previously approved these changes Aug 2, 2024
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

OK, but a couple of niggles.

@@ -215,6 +207,9 @@ protected void normalizeRequest(HttpRequest request)
request.addHeader(new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH, contentLength));
}
}
// RFC 9110, section 10.1.1.
if (content == null || content.getLength() == 0)
request.headers(h -> h.remove(HttpHeader.EXPECT));
Copy link
Contributor

Choose a reason for hiding this comment

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

technically you should just remove the 100-continue value from the Expect header, but as there are currently no other defined values, this is probably OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. And we don't have an easy API in HttpFields to remove a single value.

…continue-fixes'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet
Copy link
Contributor Author

sbordet commented Aug 2, 2024

@gregw I fixed the niggles in #12111. Not a big fan of StringUtil when I can use JDK methods.

@joakime the work here does not address #9758, which I will look at separately.

firoj0

This comment was marked as spam.

@gregw
Copy link
Contributor

gregw commented Aug 2, 2024

@gregw I fixed the niggles in #12111. Not a big fan of StringUtil when I can use JDK methods.

In this case, the StringUtil method avoids an allocation and is much clearer to read

lorban
lorban previously approved these changes Aug 7, 2024
@garydgregory
Copy link
Contributor

garydgregory commented Aug 12, 2024

Hi All,

Would you please set expectations as to next steps? Are we waiting on a review from @gregw ?

TY!

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from firoj0 and lorban and removed request for firoj0 August 13, 2024 09:23
@sbordet
Copy link
Contributor Author

sbordet commented Aug 13, 2024

@garydgregory this PR is almost ready to be merged in, we won't wait for @gregw (currently in vacation).

It will be in the next Jetty 12 release, due end of month.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested a review from lorban August 13, 2024 10:31
@sbordet sbordet merged commit fc9cbda into jetty-12.0.x Aug 13, 2024
10 checks passed
@sbordet sbordet deleted the fix/jetty-12.0.x/httpsender-proxy-continue-fixes branch August 13, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot invoke "org.eclipse.jetty.client.transport.HttpExchange.getRequest()" because "exchange" is null
6 participants