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

The content is not sent to my API #49

Closed jmgalzate closed 9 months ago

jmgalzate commented 11 months ago

Describe the bug I'm sending a PUT request with all the required information (Header, URL, Body), but the body is not sent from JetClient to my API, so I'm receiving an empty request.

Steps to reproduce

API software: PHP/Symfony API.

#[Route('/order', name: 'updateOrder', methods: ['PUT'])]
    public function updateOrder (Request $request): JsonResponse {

        if (!$request->headers->has('Accept') || $request->headers->get('Accept') !== 'application/json') {
            return new JsonResponse('Unauthorized', Response::HTTP_UNAUTHORIZED);
        }

        $jsonResponse = new JsonResponse([
            'code' => $request->getAcceptableContentTypes(),
            'message' => $request->getContent()
        ]);
        $jsonResponse->setStatusCode(Response::HTTP_OK);

        return $jsonResponse;
    }

This is the information I'm sending this payload. If I use Postman, HttpClient, or CURL in the terminal, it works, but when using JetClient, the content is not sent.

PUT https://127.0.0.1:8000/order Accept: application/json Content-Type: application/json

{
  "id" : 3,
  "order": 12345,
  "customer": 12345,
  "createdAt": "2023-12-17 03:40:12.454603"
}

JetClient Request.

image

Result with Empty content:

image

HttpClient Request

image

Expected behavior The expected behavior is to receive the full content when using the JetClient plugin

Environment information:

AntonShuvaev commented 9 months ago

Thank you for reporting this issue. It appears that JetClient wasn't adhering to the specified HTTP protocol version in the plugin settings, defaulting to HTTP/2 for PHP/Symfony API. This caused the Content-Length header to be omitted, as it's not required for HTTP/2. However, Symfony doesn't process this correctly, resulting in an empty body. The bug has now been fixed.