JetClient / jet-client-support

JetClient is an advanced REST API Client plugin for JetBrains IDEs
https://plugins.jetbrains.com/plugin/21173-jetclient
111 stars 0 forks source link

Content-type Header is automatically changed based on extension used in binary file in Body #98

Closed MsUpstream closed 3 months ago

MsUpstream commented 3 months ago

Describe the bug The header "Content-type" is automatically changed to application/json when I add a binary file in Body with .json extension.

Steps to reproduce God to Header-tab for a request. Add Content-type header with value "application/gibberish" or "application/xml". Then go to Body-tab, choose Binary file in the dropdown, and choose a file with .json-extension. Go back to Header-tab. Value for Content-type has been changed to "application/json".

Expected behavior As a tester I want to be able to test for erroneous usage of the API I am testing. I want to test how the API responds when the body in the request does not contain the given Content-type. Since Content-type is automatically changed, I am not able to write tests according to the test cases and criteria I wish to test.

The described behavior of JetClient also happens if I type in the Content-type after choosing the desired file, then edit a different request, and go back to the initial request. Hence, running the test as part of a collection or test-suite does not work as intended, as the request is altered. I don´t mind a warning letting me know I have inconsistencies in my request. However, using JetClient for testing purposes, these inconsitencies may be what I want to test. Having the errors I put in on purpse automatically changed destroys my test.

Environment information:

AntonShuvaev commented 3 months ago

Thanks for reporting this issue. I will fix it in the next version.

AntonShuvaev commented 3 months ago

The issue has been fixed in version 2024.3.3. The auto-generated Content-Type header is now separated from user-defined headers and is hidden by default. You can toggle its visibility in the table options. To overwrite it, specify your own Content-Type header; the last one will be used. If you don't need the auto-generated header, you can disable it.

light-developer commented 3 months ago

The issue has been fixed in version 2024.3.3. The auto-generated Content-Type header is now separated from user-defined headers and is hidden by default. You can toggle its visibility in the table options. To overwrite it, specify your own Content-Type header; the last one will be used. If you don't need the auto-generated header, you can disable it.

@AntonShuvaev JetClient still not work when you provide: auto-generated Content-Type

If I not add manual: Content-Type: application/json (API not work) image

AntonShuvaev commented 3 months ago

@light-developer, thanks for reporting this bug. I'll fix it ASAP.

AntonShuvaev commented 3 months ago

@light-developer, the bug has been fixed in 2024.3.6