eclipse-ee4j / eclipse-ee4j/krazo-extensions

Krazo returns arbitrarily content-types

Open
#3 1 comment 0 reactions 0 assignees View on GitHub
ext:thymeleaf
Dominant language
Java
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

I'm using Krazo on Wildfly/Resteasy with the Thymeleaf extension and noticed that the content-type handling seems to be broken. When requesting a page without an accept-header I get the default content type 'application/octet-stream;charset=UTF-8'. I would have expected "text/html":

```
❯ curl -s -v -o /dev/null 'http://localhost:8080/mvc-hotwire-1.0-SNAPSHOT/mvc/bulletins'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /mvc-hotwire-1.0-SNAPSHOT/mvc/bulletins HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-CSRF-TOKEN: ba1b2530-27bb-48b2-95b2-a3eab6c537cd
< Set-Cookie: JSESSIONID=eFCzx8Ky1y8V_GuTB8hxDMGWhxGcFestsPBtJ7QM.macbook-pro-4; path=/mvc-hotwire-1.0-SNAPSHOT
< Transfer-Encoding: chunked
< Content-Type: application/octet-stream;charset=UTF-8
< Date: Sun, 18 Apr 2021 17:58:08 GMT
```

I can even set any Accept-Header and Krazo will return it as content-type:

```
❯ curl -s -v -o /dev/null 'http://localhost:8080/mvc-hotwire-1.0-SNAPSHOT/mvc/bulletins' -H 'Accept: application/xml'
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /mvc-hotwire-1.0-SNAPSHOT/mvc/bulletins HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: application/xml
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-CSRF-TOKEN: 8ab219ff-7d4d-4588-8e49-5d42844ac12d
< Set-Cookie: JSESSIONID=U4JmvO-b8yV8W4E3tyTArbVbVYpWlWk1heJkFtFo.macbook-pro-4; path=/mvc-hotwire-1.0-SNAPSHOT
< Transfer-Encoding: chunked
< Content-Type: application/xml;charset=UTF-8
```

I do not have a "produces" annotation in the controller. If I explicitly set the content-type via `@Produces("text/html")` I get the correct content-type.

The spec states that the default content type should be "text/html". Further, I would expect that krazo does not echo back any content-type set by the accept header, but sticks to the supported Mime-Types (either defined by the engine or the framework).

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.