apache / shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
https://shenyu.apache.org/
Apache License 2.0
8.44k stars 2.93k forks source link

[BUG] add Cryptor plugin , error: Bad Request , message:Failed to read HTTP message #2218

Closed likedong closed 3 years ago

likedong commented 3 years ago

Is there an existing issue for this?

Current Behavior

image image

Expected Behavior

Return decryption information

Steps To Reproduce

  1. shenyu-bootstrap

      <dependency>
        <groupId>org.apache.shenyu</groupId>
        <artifactId>shenyu-spring-boot-starter-plugin-divide</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.shenyu</groupId>
        <artifactId>shenyu-spring-boot-starter-plugin-httpclient</artifactId>
        <version>${project.version}</version>
    </dependency>     
    <dependency>
        <groupId>org.apache.shenyu</groupId>
        <artifactId>shenyu-spring-boot-starter-plugin-cryptor</artifactId>
        <version>${project.version}</version>
     </dependency>
  2. run shenyu-admin(mysql db) 、shenyu-bootstrap、shenyu-examples-http

3.request localhost:9195/http/order/save

Environment

ShenYu version(s):master

Debug logs

Request Uri: http://localhost:9195/http/order/save Request Method: POST

[Request Headers Start] Content-Type: application/json User-Agent: PostmanRuntime/7.28.4 Accept: / Postman-Token: e9ee9cc1-58bb-413b-9524-9c079a5ff0db Host: localhost:9195 Accept-Encoding: gzip, deflate, br Connection: keep-alive Transfer-Encoding: chunked [Request Headers End]

[Request Body Start] 123123 [Request Body End]

Response Code: 200 OK

[Response Headers Start] transfer-encoding: chunked Content-Type: application/json Content-Length: 163 [Response Headers End]

[Response Body Start] {"timestamp":"2021-10-13T12:23:38.607+0000","path":"/order/save","status":400,"error":"Bad Request","message":"Failed to read HTTP message","requestId":"6bdb82c3"} [Response Body End]

likedong commented 3 years ago

The returned 'JSON' is not in the correct format. You need to comment the following code. image

JooKS-me commented 3 years ago

@impactCn Hi, does those lines should be delete? I met the same problem. image

impactCn commented 3 years ago

@impactCn Hi, does those lines should be delete? I met the same problem. image

That's the design. If decryption is encountered, replace the current body content.

JooKS-me commented 3 years ago

@impactCn Hi, does those lines should be delete? I met the same problem. image

That's the design. If decryption is encountered, replace the current body content.

Thanks, get it, and I found description in document (https://shenyu.apache.org/docs/next/plugin-center/authority-and-certification/cryptor-request-plugin/#description).