Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55262

Missing content-type on serverStatuses REST API

XMLWordPrintable

      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>

            kroking Mahmoud
            framillien Florian Ramillien
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: