eclipse-ee4j / eclipse-ee4j/jersey

HttpUrlConnector and JettyConnector doesn't log the headers modified by MultiPartWriter

Open
#5,529 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

When using the `LoggingFeature`, the actual request sent should be logged by the `LoggingInterceptor`, even if the `MultiPartFeature` is used. If the headers don't already include a header `MIME-Version` and a header `Content-Type` with a boundary, they are added by the `MultiPartWriter`:

https://github.com/eclipse-ee4j/jersey/blob/b0c503d04e1712837e7985fccca76cbc1b78e932/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/internal/MultiPartWriter.java#L122-L136

Unfortunately, the modified headers aren't logged:

```
Feb. 09, 2024 4:31:44 PM org.glassfish.jersey.logging.LoggingInterceptor log
INFORMATION: 1 * Sending client request on thread Test worker
1 > POST https://example.com/api/document
1 > Accept: application/json
1 > Content-Type: multipart/form-data
1 > User-Agent: jersey-client/3.1.5 (java)
--Boundary_1_905404580_1707400346199
Content-Type: application/octet-stream
Content-Disposition: form-data; filename="file-1065460366320764802.tmp"; size=7110; name="contents"

%PDF-1.3
%���������
...

--Boundary_1_905404580_1707400346199
Content-Type: application/json
Content-Disposition: form-data; name="metadaten"

{"name":"Passport.pdf","type":"Passport"}
--Boundary_1_905404580_1707400346199--
```

This can lead to time-consuming debugging sessions, as it requires third-party tools to be used as a [workaround to verify the actual requests](https://github.com/eclipse-ee4j/jersey/issues/5528#issuecomment-1936169488).

It seems `LoggingInterceptor` is called to early.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.