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

Type "x-www-form-urlencoded" Request Parameters Not Available #1077

Closed
flashvayne opened this issue Jun 22, 2021 · 2 comments
Closed

Type "x-www-form-urlencoded" Request Parameters Not Available #1077

flashvayne opened this issue Jun 22, 2021 · 2 comments
Labels

Comments

@flashvayne
Copy link

flashvayne commented Jun 22, 2021

Description

when I ran a Springboot Service with "logbook-spring-boot-starter",
an error occurred when a "x-www-form-urlencoded" type http request received. The reason is that some parameters from the request were not available. Although I have tried almost every version of "logbook-spring-boot-starter" and changed some environment settings, this problem could not be solved. So, I think there is probably a bug which caused this issue. I have attached the codes that can reproduce this bug. Please refer to Chapter "Steps to Reproduce" and try to reproduce it.

Expected Behavior

Parameters from http request should be available. The error mentioned in Description does not occur when component "logbook-spring-boot-starter" is not used.

Actual Behavior

Parameters from http request were not available. They were all null instead of their original values.

Possible Fix

Steps to Reproduce

Springboot controller code is as below:

@PostMapping("/test")
    public void test(@Param("documentId") String documentId,
                             @Param("result") String result) {
        System.out.println("documentId : " + documentId);
        System.out.println("result : " + result);
    }

Springboot application.yml code is as below:

server:
  port: 8080
logging:
  level:
    org:
      zalando:
        logbook: trace
logbook:
  format:
    style: http

Request curl command is as below:

  curl --location --request POST '127.0.0.1:8080/test' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'documentId=123456' \
  --data-urlencode 'result=success'

Code "System.out.println" output contents are as below:

documentId : null
result : null

Context

Due to this bug, I had to use InputStream to parse those parameters from http request, which is very complicated.

Your Environment

  • Version used: JDK 1.8, Springboot 2.3.0.RELEASE
  • Link to your project:
@flashvayne flashvayne added the Bug label Jun 22, 2021
@whiskeysierra
Copy link
Collaborator

@zhfkt
Copy link

zhfkt commented Jan 8, 2022

I tried the following configuration and it seems work.

logbook:
  filter:
    form-request-mode: off

I tried the recommended way to set form-request-mode. Only x-www-form-urlencoded data will not be recorded and other type of post action (such as application/json) will still be logged. So I think it may work currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants