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

fix: Remove default content-length header from MultipartStreamBuilder class #63

Merged
merged 3 commits into from
Sep 1, 2024

Conversation

chris-lee-lb
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets N/A
Documentation N/A
License MIT

What's in this PR?

Remove default Content-Length header from MultipartStreamBuilder class.

Why?

Content-Length in multipart bodies is not necessary. Some legacies system can't manage the "Content-Length" header into "multipart/form-data" boundary and cut off the request.

Currently I had face this problem with Azure OpenAI upload files API.

For reference see the RFC 7578 in section 4.8 which specify:

4.8. Other "Content-" Header Fields

The multipart/form-data media type does not support any MIME header
fields in parts other than Content-Type, Content-Disposition, and (in
limited circumstances) Content-Transfer-Encoding. Other header
fields MUST NOT be included and MUST be ignored
.

Older system are not compliant because not apply the MUST be ignore policy but on the other side this code non apply the MUST NOT be included policy. So the Azure OpenAI API server is designed to be RFC compliant.

Example Usage

N/A

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)

@chris-lee-lb
Copy link
Contributor Author

Some another library references : guzzle/psr7#581

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

thanks for the RFC reference. yeah makes sense.

also boo microsoft for not being robust.

CHANGELOG.md Outdated Show resolved Hide resolved
tests/FunctionTest.php Outdated Show resolved Hide resolved
tests/FunctionTest.php Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/MultipartStreamBuilder.php Show resolved Hide resolved
src/MultipartStreamBuilder.php Show resolved Hide resolved
src/MultipartStreamBuilder.php Show resolved Hide resolved
Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

sorry, will do the weird styleci thing. not related to your changes.

we should use the phpstan array format for this parameter actually... but out of scope for this pr

src/MultipartStreamBuilder.php Outdated Show resolved Hide resolved
src/MultipartStreamBuilder.php Outdated Show resolved Hide resolved
src/MultipartStreamBuilder.php Outdated Show resolved Hide resolved
@dbu dbu merged commit 4087940 into php-http:1.x Sep 1, 2024
13 checks passed
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.

2 participants