Solr
  1. Solr
  2. SOLR-4110

Configurable Content-Type headers for PHPResponseWriters and PHPSerializedResponseWriter

    Details

      Description

      The PHPResponseWriter and PHPSerializedResponseWriter currently send a hard coded Content-Type header of text/plain; charset=UTF-8 although there are constants defining text/x-php;charset=UTF-8 and text/x-php-serialized;charset=UTF-8 which remain unused. This makes content type guessing on the client side quite complicated.

      I already created a patch (from the branch_4x github branch) to use the respective constants and also added the possibility to configure the Content-Type header via solrconfig.xml (like in JSONResponseWriter).

      1. SOLR-4110_branch_4x.patch
        2 kB
        Dominik Siebel
      2. SOLR-4110_trunk.patch
        3 kB
        Dominik Siebel
      3. SOLR-4110.patch
        2 kB
        Dominik Siebel

        Activity

        Hide
        Mark Miller added a comment -

        What about back compat? How might this affect those upgrading from 4.0?

        Show
        Mark Miller added a comment - What about back compat? How might this affect those upgrading from 4.0?
        Hide
        Dominik Siebel added a comment - - edited

        Upgrading from 4.0?

        I don't see any harm in the ResponseWriters being configurable. JSONResponseWriter already is (as far as Content-Type header in concerned).
        Sending text/x-php;charset=UTF-8 as default however might be an issue, yes (if anyone really relies on text/plain for PHP and PHPs).
        But since the Content-Type header of the ResponseWriters would be configurable you could still overwrite the defaults in solrconfig.xml just like the example does with the JSONResponseWriter:

        <queryResponseWriter name="json" class="solr.JSONResponseWriter">
        	<!-- For the purposes of the tutorial, JSON responses are written as
        	  plain text so that they are easy to read in *any* browser.
        	  If you expect a MIME type of "application/json" just remove this override.
        	-->
        	<str name="content-type">text/plain; charset=UTF-8</str>
        </queryResponseWriter>
        
        Show
        Dominik Siebel added a comment - - edited Upgrading from 4.0? I don't see any harm in the ResponseWriters being configurable. JSONResponseWriter already is (as far as Content-Type header in concerned). Sending text/x-php;charset=UTF-8 as default however might be an issue, yes (if anyone really relies on text/plain for PHP and PHPs). But since the Content-Type header of the ResponseWriters would be configurable you could still overwrite the defaults in solrconfig.xml just like the example does with the JSONResponseWriter : <queryResponseWriter name= "json" class= "solr.JSONResponseWriter" > <!-- For the purposes of the tutorial, JSON responses are written as plain text so that they are easy to read in *any* browser. If you expect a MIME type of "application/json" just remove this override. --> <str name= "content-type" > text/plain; charset=UTF-8 </str> </queryResponseWriter>
        Hide
        Mark Miller added a comment -

        Okay - if no one complains I'll just commit this change then.

        Show
        Mark Miller added a comment - Okay - if no one complains I'll just commit this change then.
        Hide
        Mark Miller added a comment -

        Could you update this patch to 4x or trunk Dominik - looks like some thing have changed. I don't have the time to do it myself right now, but if you do, I can certainly commit it.

        Show
        Mark Miller added a comment - Could you update this patch to 4x or trunk Dominik - looks like some thing have changed. I don't have the time to do it myself right now, but if you do, I can certainly commit it.
        Hide
        Dominik Siebel added a comment -

        Will do, might have to wait until Sunday, though.

        Show
        Dominik Siebel added a comment - Will do, might have to wait until Sunday, though.
        Hide
        Dominik Siebel added a comment -

        Patch to make Content-Type header configurable in PHPResponseWriters.

        Had to add two patches for trunk and branch_4x separately, due to changes in trunk ("missing @Overrides").

        Show
        Dominik Siebel added a comment - Patch to make Content-Type header configurable in PHPResponseWriters. Had to add two patches for trunk and branch_4x separately, due to changes in trunk ("missing @Overrides").
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] Mark Robert Miller
        http://svn.apache.org/viewvc?view=revision&revision=1423121

        SOLR-4110: Configurable Content-Type headers for PHPResponseWriters and PHPSerializedResponseWriter.

        Show
        Commit Tag Bot added a comment - [trunk commit] Mark Robert Miller http://svn.apache.org/viewvc?view=revision&revision=1423121 SOLR-4110 : Configurable Content-Type headers for PHPResponseWriters and PHPSerializedResponseWriter.
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Mark Robert Miller
        http://svn.apache.org/viewvc?view=revision&revision=1423123

        SOLR-4110: Configurable Content-Type headers for PHPResponseWriters and PHPSerializedResponseWriter.

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Mark Robert Miller http://svn.apache.org/viewvc?view=revision&revision=1423123 SOLR-4110 : Configurable Content-Type headers for PHPResponseWriters and PHPSerializedResponseWriter.
        Hide
        Mark Miller added a comment -

        Thanks Dominik!

        Show
        Mark Miller added a comment - Thanks Dominik!

          People

          • Assignee:
            Mark Miller
            Reporter:
            Dominik Siebel
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development