Skip to content

Added body size limit option to AmpHttpClient #58873

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

Closed
wants to merge 3 commits into from
Closed

Conversation

Kinqdos
Copy link

@Kinqdos Kinqdos commented Nov 14, 2024

Q A
Branch 7.2
Bug fix? no
New feature? no
Deprecations? no
Issues Body size limit always capped at ~10 MB with AmpHttpClient
License MIT

I added the option body_size_limit to the AmpHttpClient to be able to increase the default from AmpHttpClient, wich is ~10 MB.

@carsonbot carsonbot added this to the 7.2 milestone Nov 14, 2024
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@Kinqdos
Copy link
Author

Kinqdos commented Nov 14, 2024

Failing tests are in completely different components. My code doesn't affect those components.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I'd rather always call setBodySizeLimit(0) to remove any limits, since the other clients don't have one anyway. Can you please update accordingly?

@nicolas-grekas
Copy link
Member

Oh, and I'd be fine fixing this on branch 5.4 as a bugfix.

@Kinqdos Kinqdos changed the base branch from 7.2 to 5.4 November 14, 2024 14:21
@Kinqdos
Copy link
Author

Kinqdos commented Nov 14, 2024

Oh, and I'd be fine fixing this on branch 5.4 as a bugfix.

Are you sure I can change this pull request? Or should I create a new one?

@Kinqdos Kinqdos changed the base branch from 5.4 to 7.2 November 14, 2024 14:23
@Kinqdos Kinqdos closed this Nov 14, 2024
nicolas-grekas added a commit that referenced this pull request Nov 14, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[HttpClient] Removed body size limit

| Q             | A
| ------------- | ---
| Branch       | 5.4
| Bug fix      | yes
| New feature  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | Fixes Body size limit of ~10 MB in AmpHttpClient
| License       | MIT

See #58873
<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the latest branch.
 - For new features, provide some code snippets to help understand usage.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

Commits
-------

122a480 Removed body size limit
@nuncanada
Copy link
Contributor

This seems to cause Body Size problems with importmap:install !

PS C:\Users\flaviobb\Desktop\ProjetosContratos-pncp\contratos_symfony> composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run composer update or composer update .
Nothing to install, update or remove
Package league/uri-parser is abandoned, you should avoid using it. Use league/uri-interfaces instead.
Generating autoload files
129 packages you are using are looking for funding.
Use the composer fund command to find out more!

Run composer recipes at any time to see the status of your Symfony recipes.

Executing script cache:clear [OK]
Executing script importmap:install [KO]
[KO]
Script importmap:install returned with error code 1
!! 0/21 >--------------------------- https://cdn.jsdelivr.net/npm/jquery-ui@1.13.2/+esm
!! In ErrorChunk.php line 73:
!!
!! Body size limit exceeded
!!
!!
!! In Http2ConnectionProcessor.php line 711:
!!
!! Body size limit exceeded
!!
!!
!! In Http2ConnectionProcessor.php line 757:
!!
!! Body size limit exceeded
!!
!!
!! importmap:install
!!
!!
Script @auto-scripts was called via post-install-cmd

Once I changed that line from
$request->setBodySizeLimit(0);
To
$request->setBodySizeLimit(10000000000000000);

Everything worked just fine!!!

@nuncanada
Copy link
Contributor

nuncanada commented Dec 23, 2024

My importmap.php:

<?php

/**
 * Returns the importmap for this application.
 *
 * - "path" is a path inside the asset mapper system. Use the
 *     "debug:asset-map" command to see the full list of paths.
 *
 * - "entrypoint" (JavaScript only) set to true for any module that will
 *     be used as an "entrypoint" (and passed to the importmap() Twig function).
 *
 * The "importmap:require" command can be used to add new entries to this file.
 */
return [
    'jquery-ui' => [
        'version' => '1.13.2',
    ],
    'jquery' => [
        'version' => '3.7.1',
    ],
    'jquery/dist/jquery.min.js' => [
        'version' => '3.7.1',
    ],
    'bootbox' => [
        'version' => '6.0.0',
    ],
    'ckeditor' => [
        'version' => '4.12.1',
    ],
    '@fortawesome/fontawesome-free' => [
        'version' => '6.5.2',
    ],
    '@fortawesome/fontawesome-free/css/fontawesome.min.css' => [
        'version' => '6.5.2',
        'type' => 'css',
    ],
    '@fortawesome/fontawesome-svg-core' => [
        'version' => '6.5.2',
    ],
    '@fortawesome/fontawesome-svg-core/styles.min.css' => [
        'version' => '6.5.2',
        'type' => 'css',
    ],
    '@fortawesome/free-brands-svg-icons' => [
        'version' => '6.5.2',
    ],
    '@fortawesome/free-regular-svg-icons' => [
        'version' => '6.5.2',
    ],
    '@fortawesome/free-solid-svg-icons' => [
        'version' => '6.5.2',
    ],
    'bootstrap' => [
        'version' => '5.3.3',
    ],
    '@popperjs/core' => [
        'version' => '2.11.8',
    ],
    'bootstrap/dist/css/bootstrap.min.css' => [
        'version' => '5.3.3',
        'type' => 'css',
    ],
    'bootstrap5-autocomplete' => [
        'version' => '1.1.26',
    ],
    'bootstrap5-autocomplete/autocomplete.js' => [
        'version' => '1.1.26',
    ],
    
    'app' => [
        'path' => './assets/app.js',
        'entrypoint' => true,
    ],
    '@hotwired/stimulus' => [
        'version' => '3.2.2',
    ],
    'tom-select' => [
        'version' => '2.3.1',
    ],
    'tom-select/dist/css/tom-select.default.css' => [
        'version' => '2.3.1',
        'type' => 'css',
    ],
    'tom-select/dist/css/tom-select.bootstrap5.css' => [
        'version' => '2.3.1',
        'type' => 'css',
    ],
    '@stm/admin-bundle' => [
        'path' => './vendor/stm/admin-bundle/assets/StmAdmin.js',
    ],
];

@nicolas-grekas
Copy link
Member

Try upgrading amphp/http-client and its dependencies

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.

4 participants