Skip to content

fix: disable Expect: 100-continue for the Curl client of elastic/transport - #2322

Open
andrii-pukhalevych wants to merge 1 commit into
ruflin:9.xfrom
andrii-pukhalevych:fix-curl-100-continue
Open

andrii-pukhalevych wants to merge 1 commit into
ruflin:9.xfrom
andrii-pukhalevych:fix-curl-100-continue

Conversation

@andrii-pukhalevych

Copy link
Copy Markdown

For a body over 1 MB curl adds Expect: 100-continue on its own, and Elastic\Transport\Client\Curl takes the interim 100 Continue answer for the response: status 100 with no headers, so every such request fails with "No Content-Type specified in the response".

Keep the header out of the requests when that client is in use, and cover it with a unit test and a functional test with a 1.2 MB search.

Fixes #2321

…sport

  For a body over 1 MB curl adds `Expect: 100-continue` on its own, and
  `Elastic\Transport\Client\Curl` takes the interim `100 Continue` answer
  for the response: status 100 with no headers, so every such request
  fails with "No Content-Type specified in the response".

  Keep the header out of the requests when that client is in use, and
  cover it with a unit test and a functional test with a 1.2 MB search.

  Fixes ruflin#2321
Comment thread src/Client.php
* and the Curl client of elastic/transport takes "100 Continue" for the response
*/
if ($this->isCurlHttpClient($transport)) {
$transport->setHeader('Expect', '');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This means if a user set their own Expect header, it would be reset? Likely a rare edge case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Surprisely yes. And it's real project where this happens.

@ruflin

ruflin commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Related: the root-cause fix is now a draft PR upstream, elastic/elastic-transport-php#48 (Curl skips the interim 100 Continue response).

This PR is still worth having for users on older elastic/transport versions, and it does not conflict with the upstream fix. Once a release with the fix exists we can raise the minimum elastic/transport version and decide whether to keep or drop the workaround.

@ruflin

ruflin commented Oct 28, 2026

Copy link
Copy Markdown
Owner

@andrii-pukhalevych Could you take a look at elastic/elastic-transport-php#48 I had sent my agent to create it ;-)

This branch has not been deployed

No deployments
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.

Curl client parses the "100 Continue" interim response as the final response (requests over 1 MB fail with UnknownContentTypeException)

2 participants