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 empty data param to cURL if no POST request body was given #6017

Merged

Conversation

mircohacker
Copy link

Description

This changes adds a simple -d '' to the curl command if the request method is POST and no request body is given.

Motivation and Context

Some middleware applications do not allow POST requests without a content-length header. By adding a empty data parameter to the curl command, the content-length header will be set by curl. Besides this it is more obvious to the user that no request body is sent.

An example for such a middleware is apigee.

How Has This Been Tested?

This has been tested manually by observing the curl command given a POST request and an empy request body.

A unit test has been added to verify the implemented behavior.

No breaking changes in other areas of the code are verified by running npm run just-test-in-node e2e-cypress lint-errors

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests. (This PR covers only an edge case)
  • All new and existing tests passed.

Mirco Haug added 2 commits May 18, 2020 10:10
Some middleware applications do not allow POST requests without a content-length header. By adding a empty data parameter to the curl command, the content-length header will be set by curl. Besides this it is more obvious to the user that no request body is sent.
@mircohacker mircohacker force-pushed the feature/empty-data-param-on-empty-post branch from d36b3c9 to d0acf91 Compare May 18, 2020 11:42
@tim-lai tim-lai self-assigned this May 28, 2020
@tim-lai tim-lai merged commit eaca2f6 into swagger-api:master May 29, 2020
@tim-lai
Copy link
Contributor

tim-lai commented May 29, 2020

@mircohaug Merged! Thanks for the contribution!

mattyb678 pushed a commit to mattyb678/swagger-ui that referenced this pull request Jun 24, 2020
…er-api#6017)

* Add empty data param to cURL if no request body was given

Some middleware applications do not allow POST requests without a content-length header. By adding a empty data parameter to the curl command, the content-length header will be set by curl. Besides this it is more obvious to the user that no request body is sent.

* use double quotes like the rest of the curl command
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