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.41k stars 2.92k forks source link

[BUG] Using the "Cryptor Response Plugin" plugin did not return response information #2084

Closed likedong closed 2 years ago

likedong commented 2 years ago

Is there an existing issue for this?

Current Behavior

image image image

Environment

ShenYu version(s): master branch
impactCn commented 2 years ago

Can you tell me your detailed steps?

likedong commented 2 years ago

Steps To Reproduce

  1. modify shenyu-spring-boot-starter-plugin/CryptorPluginConfiguration.java ,add code @Bean public PluginDataHandler CryptorRequestPluginDataHandler() { return new CryptorRequestPluginDataHandler(); }

    @Bean public PluginDataHandler CryptorResponsePluginDataHandler() { return new CryptorResponsePluginDataHandler(); }

  2. a) modify org.apache.shenyu.plugin.cryptor.utils/HttpUtil.java,add code,As shown below image b) modify CryptorResponsePlugin ,As shown below image

  3. shenyu-bootstrap pom.xml add code

    <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>
    org.apache.shenyu shenyu-spring-boot-starter-plugin-cryptor ${project.version}

image

  1. mvn clean install -Dmaven.javadoc.skip=true -B -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests run shenyu-admin 、shenyu-bootstrap、shenyu-examples-http,postman post request http://localhost:9195/http/order/save At the same time, open the logging plugin. The log has an output response, but there is no response in "postman"
impactCn commented 2 years ago

Did you modify the code inside? What is the result of the original code? I feel that the response was consumed in advance, which caused it to be unable to return normally.

likedong commented 2 years ago

The code inside has not been modified. Do not configure 'fieldnames' ,parseBody == null , Can return normally. image

likedong commented 2 years ago

Cryptor Response Plugin , Isn't the method called encrypted? After conversion to encryption, no information is returned.

impactCn commented 2 years ago

Cryptor Response Plugin , Isn't the method called encrypted? After conversion to encryption, no information is returned.

image image image image

likedong commented 2 years ago

Refer to the modify-response plugin, modify ResponseDecorator.java , Return to normal.

image

image image