Skip to content

Commit

Permalink
Accept body only if non empty
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitozgumus committed Jun 12, 2024
1 parent 88ba1c5 commit 275263d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mockingstar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ publishing {
create<MavenPublication>("release") {
groupId = "com.trendyol.mockingstar"
artifactId = "mockingstar"
version = "1.0.0"
version = "1.0.1"
afterEvaluate {
from(components["java"])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MockingStarInterceptor(
val originalRequest = chain.request()

val buffer = Buffer()

originalRequest.body?.writeTo(buffer)

val contentType = originalRequest.body?.contentType()
Expand All @@ -31,7 +32,7 @@ class MockingStarInterceptor(
method = originalRequest.method,
url = originalRequest.url.toString(),
headers = originalRequest.headers.toMap(),
body = buffer.readString(charset),
body = buffer.readString(charset).takeIf { it.isNotEmpty() },
)
val json = Json { explicitNulls = false }
val requestString = json.encodeToString(requestBody)
Expand Down

0 comments on commit 275263d

Please sign in to comment.