Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-12282

JSONResponseWriter should return Content-Type application/javascript for JSONP requests

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Patch Available
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Response Writers
    • None

    Description

      The JSONResponseWriter handles two purposes:

      • writing JSON responses (wt=json)
      • writing JSONP responses, namely JSON responses wrapped by a JavaScript function (wt=json&json.wrf=myFunction)

      The response writer returns the same Content-Type in both cases. (default: application/json)
      But for JSONP the correct Content-Type would be "application/javascript".

      The response type is configurable, but it is currently not possible to return the correct Content-Type in both cases with one configuration at the same time.

      The attached patch changes the default Content-Type to application/javascript; charset=utf-8 for responses with wrapper functions (JSONP). If param content-type is configured, this Content-Type will be returned for both JSON and JSONP to ensure backward compatibility.

      Attachments

        1. SOLR-12282.patch
          4 kB
          Markus Schuch

        Issue Links

          Activity

            People

              Unassigned Unassigned
              schuch Markus Schuch
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: