-
Bug
-
Resolution: Fixed
-
Trivial
-
Gerrit-trigger-plugin 2.27.7
Jelly template serving /gerrit-trigger/serverStatuses REST API doesn't add a Content-Type header to HTTP Response.
In almost all cases this is harmless (JSON result is accepted) but on some combination of Browser / HTTP Proxy + Gzip compression this result to corrupted JSON response.
Actual response headers:
HTTP/1.1 200 OK Date: Wed, 19 Dec 2018 13:52:44 GMT X-Content-Type-Options: nosniff Content-Encoding: gzip Content-Length: 143 Server: Jetty(9.4.z-SNAPSHOT)
Expected response headers:
HTTP/1.1 200 OK Date: Wed, 19 Dec 2018 14:16:50 GMT X-Content-Type-Options: nosniff Content-Encoding: gzip Content-Type: application/json Content-Length: 145 Server: Jetty(9.4.z-SNAPSHOT
Adding Jelly:stapler 'contentType' tag fix this.
/src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritManagement/serverStatuses.jelly
<?jelly escape-by-default='true'?> <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt"> <st:contentType value="application/json" /> ${it.serverStatuses} </j:jelly>
[JENKINS-55262] Missing content-type on serverStatuses REST API
Description |
Original:
Jelly template serving /gerrit-trigger/serverStatuses REST API doesn't add a Content-Type header to HTTP Response. In almost all cases this is harmless (JSON result is accepted) but on some combination of Browser / HTTP Proxy + Gzip compression this result to corrupted JSON response. Actual Response headers: {code:java} HTTP/1.1 200 OK Date: Wed, 19 Dec 2018 13:52:44 GMT X-Content-Type-Options: nosniff Content-Encoding: gzip Content-Length: 143 Server: Jetty(9.4.z-SNAPSHOT){code} Expected response: {code:java} HTTP/1.1 200 OK Date: Wed, 19 Dec 2018 14:16:50 GMT X-Content-Type-Options: nosniff Content-Encoding: gzip Content-Type: application/json Content-Length: 145 Server: Jetty(9.4.z-SNAPSHOT{code} Adding Jelly:stapler 'contentType' tag fix this. /src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritManagement/serverStatuses.jelly {code:java} <?jelly escape-by-default='true'?> <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt"> <st:contentType value="application/json" /> ${it.serverStatuses} </j:jelly>{code} |
New:
Jelly template serving /gerrit-trigger/serverStatuses REST API doesn't add a Content-Type header to HTTP Response. In almost all cases this is harmless (JSON result is accepted) but on some combination of Browser / HTTP Proxy + Gzip compression this result to corrupted JSON response. Actual response headers: {code:java} HTTP/1.1 200 OK Date: Wed, 19 Dec 2018 13:52:44 GMT X-Content-Type-Options: nosniff Content-Encoding: gzip Content-Length: 143 Server: Jetty(9.4.z-SNAPSHOT){code} Expected response headers: {code:java} HTTP/1.1 200 OK Date: Wed, 19 Dec 2018 14:16:50 GMT X-Content-Type-Options: nosniff Content-Encoding: gzip Content-Type: application/json Content-Length: 145 Server: Jetty(9.4.z-SNAPSHOT{code} Adding Jelly:stapler 'contentType' tag fix this. /src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritManagement/serverStatuses.jelly {code:java} <?jelly escape-by-default='true'?> <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt"> <st:contentType value="application/json" /> ${it.serverStatuses} </j:jelly>{code} |
Labels | New: newbie-friendly |
Labels | Original: newbie-friendly | New: newbie-friendly rest |
Assignee | Original: rsandell [ rsandell ] | New: Mahmoud [ kroking ] |
Released As | New: https://github.com/jenkinsci/gerrit-trigger-plugin/releases/tag/gerrit-trigger-2.29.0 | |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Open [ 1 ] | New: Closed [ 6 ] |
In our case, missing content-type header cause problem with:
JS client receive base64 instead of expected JSON leading to "Data error." in servers list.