[JIRA] (JENKINS-55262) Missing content-type on serverStatuses REST API

2 views
Skip to first unread message

florian@ramillien.fr (JIRA)

unread,
Dec 19, 2018, 9:23:01 AM12/19/18
to jenkinsc...@googlegroups.com
Florian Ramillien created an issue
 
Jenkins / Bug JENKINS-55262
Missing content-type on serverStatuses REST API
Issue Type: Bug Bug
Assignee: rsandell
Components: gerrit-trigger-plugin
Created: 2018-12-19 14:22
Environment: Gerrit-trigger-plugin 2.27.7
Priority: Trivial Trivial
Reporter: Florian Ramillien

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:

 

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>
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

florian@ramillien.fr (JIRA)

unread,
Dec 19, 2018, 9:29:01 AM12/19/18
to jenkinsc...@googlegroups.com
Florian Ramillien commented on Bug JENKINS-55262
 
Re: Missing content-type on serverStatuses REST API

In our case, missing content-type header cause problem with:

  • HTTP response compressed in gzip
  • Proxy: traefik (add wrong content-type: application/x-gzip)
  • Browser: Firefox (wrap raw gzip in base64)

JS client receive base64 instead of expected JSON leading to "Data error." in servers list.

florian@ramillien.fr (JIRA)

unread,
Dec 19, 2018, 9:33:03 AM12/19/18
to jenkinsc...@googlegroups.com
Florian Ramillien updated an issue
 
Change By: Florian Ramillien
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 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}

florian@ramillien.fr (JIRA)

unread,
Dec 31, 2018, 6:00:01 AM12/31/18
to jenkinsc...@googlegroups.com

martin.danjou14@gmail.com (JIRA)

unread,
Jan 17, 2019, 9:46:02 PM1/17/19
to jenkinsc...@googlegroups.com

o.v.nenashev@gmail.com (JIRA)

unread,
Mar 25, 2020, 3:58:03 AM3/25/20
to jenkinsc...@googlegroups.com
Oleg Nenashev updated an issue
Change By: Oleg Nenashev
Labels: newbie-friendly rest
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages