You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The request body is being printed out only if the content type is set to application/x-www-form-urlencoded. Otherwise, it will not be printed. Am I missing to include some extra dependencies or maybe some required configuration is missing?
To Reproduce
build.gradle:
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.6'
id 'io.spring.dependency-management' version '1.1.0'
}
group ='com.example'
version ='0.0.1-SNAPSHOT'
sourceCompatibility ='17'
repositories {
mavenCentral()
}
dependencies {
implementation 'dev.akkinoc.spring.boot:logback-access-spring-boot-starter:4.0.0'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
For example, curl -X POST localhost:8989/api/login -H "content-type: application/x-www-form-urlencoded" -d 'username=a&password=b' works as expected, while curl -X POST localhost:8989/api/login -H "content-type: application/json" -d '{"username":"a","password":"b"}' does NOT work at all - the request body is missing.
Expected behavior
It would be nice if it worked well even for some other content types, primarily for application/json.
POST /api/login HTTP/1.1accept: */*content-length: 21content-type: application/jsonhost: localhost:8989user-agent: curl/8.0.1
{"username":"a","password":"b"}
ghost
changed the title
The request body is being printed out only if the content type is set to application/x-www-form-urlencoded.
The request body is being printed out only if the content type is set to application/x-www-form-urlencoded. Not otherwise.
May 8, 2023
Describe the bug
The request body is being printed out only if the content type is set to
application/x-www-form-urlencoded
. Otherwise, it will not be printed. Am I missing to include some extra dependencies or maybe some required configuration is missing?To Reproduce
build.gradle:
application.yml:
logback-access.xml:
For example,
curl -X POST localhost:8989/api/login -H "content-type: application/x-www-form-urlencoded" -d 'username=a&password=b'
works as expected, whilecurl -X POST localhost:8989/api/login -H "content-type: application/json" -d '{"username":"a","password":"b"}'
does NOT work at all - the request body is missing.Expected behavior
It would be nice if it worked well even for some other content types, primarily for
application/json
.or even better, formatted as:
Environment
The text was updated successfully, but these errors were encountered: