incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Re: Default response is text/plain
Date Mon, 02 Feb 2009 17:28:45 GMT
On Mon, Feb 02, 2009 at 08:34:58AM -0800, Chris Anderson wrote:
> On Mon, Feb 2, 2009 at 3:07 AM, Paul Davis <paul.joseph.davis@gmail.com> wrote:
> > Brian,
> >
> > Link Jan say, as far as my recollection goes this was to get browser
> > viewing correct. If you felt like reworking things so that the Accept
> > header were treated more correctly including the weights etc I don't
> > think anyone would argue with more closely supporting the spec.
> >
> 
> I prefer being able to look at the responses in the browser, and it's
> not hurting anything. I think the way things are is fine.
> 
> (Maybe there's a way to get most browsers to display application/json
> instead of making a file?)

I tried a patch to return application/json unless the UA asked for
text/plain, and got a 'Save as' box in Firefox.

OK, I see the problem. Firefox says

  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

but doesn't explicitly accept text/plain or even text/*

I guess for any client for which cares about getting the correct
Content-Type, then it cares enough to provide the right Accept: header.
e.g. for couchrest:

--- lib/couchrest/monkeypatches.rb.orig	2009-02-02 17:24:52.000000000 +0000
+++ lib/couchrest/monkeypatches.rb	2009-02-02 17:25:30.000000000 +0000
@@ -35,4 +35,10 @@
     :url => url,
     :headers => headers)
   end
-end
\ No newline at end of file
+
+  class Request
+    def default_headers
+      { :accept => 'application/json', :accept_encoding => 'gzip, deflate' }
+    end
+  end
+end

Regards,

Brian.

Mime
View raw message