eclipse-ee4j / eclipse-ee4j/jersey

Empty 'Accept' header is added to request if the input is null or an empty string

Open
#4,407 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

Hello!

We're currently using the jersey-client-2.25.1 in our project and we did an update of the openapi-generator-cli-4.2.3 for generating our api clients.

In the old version of the generator the parameter for the accept header for a DELETE request looked like this:

```
final String[] localVarAccepts = {
"application/json", "application/xml"
};
```
in the new version they changed it to:

```
final String[] localVarAccepts = {

};
```

The values of these arrays were merged to a comma separated string and passed to the accept method of the ClientRequest.class:

```
/**
* Add new accepted types to the message headers.
*
* @param types accepted types to be added.
*/
public void accept(final String... types) {
getHeaders().addAll(HttpHeaders.ACCEPT, (Object[]) types);
}
```

The problem is that the REST web service which we're targeting can't handle empty 'Accept' headers, and in my opinion it shouldn't be able to, since the 'Accept' header shouldn't be set on the DELETE request if the input value is empty or null. Therefore it would be great if there is a way to tell Jersey not to add the default value or an empty header when a null or an empty string is used.

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.