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

Missing content-type on serverStatuses REST API

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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>

        Attachments

          Activity

          Hide
          framillien Florian Ramillien added a comment -

          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.

          Show
          framillien Florian Ramillien added a comment - 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.
          Show
          framillien Florian Ramillien added a comment - Linked pull request : https://github.com/jenkinsci/gerrit-trigger-plugin/pull/388

            People

            • Assignee:
              rsandell rsandell
              Reporter:
              framillien Florian Ramillien
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: