Uploaded image for project: 'REST Client'
  1. REST Client
  2. MGNLRESTCL-100

Cannot render some HTTP response codes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 2.0
    • 2.0
    • None
    • None

       

      We should make sure that if we get an HTTP response code in a response and if our primary goal is knowing what the Status or StatusInfo is, we should be able to display that (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). 

      Two examples

      (Common client config)

      baseUrl: 'http://httpbin.org/'
      class: 'info.magnolia.rest.client.ConfiguredRestClientDefinition'
      clientFactoryClass: 'info.magnolia.rest.client.factory.DefaultClientFactory'
      
      restCalls:
        requestCode:
          method: 'GET'
          entityClass: 'java.lang.String'
          path: 'status/{code}'
          defaultValues:
            code: 404
        requestJson:
          method: 'GET'
          entityClass: 'com.fasterxml.jackson.databind.JsonNode'
          path: 'json'
      

       
      Example: Code 204 - No Content

      [#assign code204Call = restfn.call("errors", "requestCode", {"code": 204})]
      
      <p>
          <b>code204Call:</b> ${code204Call.getEntity()?has_content?then(code204Call.getEntity(), code204Call.getStatus())}
      </p>
      

      Requesting 204 via curl you get "204 NO CONTENT"

      martin@ryzen5 ~ $ curl -I http://httpbin.org/status/204?
      HTTP/1.1 204 NO CONTENT
      Access-Control-Allow-Credentials: true
      Access-Control-Allow-Origin: *
      Content-Type: text/html; charset=utf-8
      Date: Fri, 22 Nov 2019 11:48:25 GMT
      Referrer-Policy: no-referrer-when-downgrade
      Server: nginx
      X-Content-Type-Options: nosniff
      X-Frame-Options: DENY
      X-XSS-Protection: 1; mode=block
      Connection: keep-alive
      

      Magnolia displays "200" instead:

       

      Example: Code 205 - Reset Content

      [#assign code205Call = restfn.call("errors", "requestCode", {"code": 205})]
      
      <p>
          <b>code205Call:</b> ${code205Call.getEntity()?has_content?then(code205Call.getEntity(), code205Call.getStatus())}
      </p>
      

      Requesting 205 via curl you get "205 RESET CONTENT"

      martin@ryzen5 ~ $ curl -I http://httpbin.org/status/205?
      HTTP/1.1 205 RESET CONTENT
      Access-Control-Allow-Credentials: true
      Access-Control-Allow-Origin: *
      Content-Length: 0
      Content-Type: text/html; charset=utf-8
      Date: Fri, 22 Nov 2019 11:48:29 GMT
      Referrer-Policy: no-referrer-when-downgrade
      Server: nginx
      X-Content-Type-Options: nosniff
      X-Frame-Options: DENY
      X-XSS-Protection: 1; mode=block
      Connection: keep-alive
      

      Magnolia doesn't show "205", but instead complains about receiving no entity:

        Acceptance criteria

          1. image-2019-11-22-13-34-11-837.png
            4 kB
            Martin Drápela
          2. image-2019-11-22-13-35-57-981.png
            27 kB
            Martin Drápela

              jsimak Jaroslav Simak
              mdrapela Martin Drápela
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 4.5h
                    4.5h