Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 846759E07 for ; Tue, 13 Mar 2012 21:11:40 +0000 (UTC) Received: (qmail 75900 invoked by uid 500); 13 Mar 2012 21:11:40 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 75876 invoked by uid 500); 13 Mar 2012 21:11:40 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 75866 invoked by uid 99); 13 Mar 2012 21:11:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 21:11:40 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lutter@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 21:11:34 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2DLBCVE005403 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 Mar 2012 17:11:12 -0400 Received: from [10.3.113.150] (ovpn-113-150.phx2.redhat.com [10.3.113.150]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2DLBCjS029627 for ; Tue, 13 Mar 2012 17:11:12 -0400 Message-ID: <1331673072.2764.92.camel@avon.watzmann.net> Subject: Re: [PATCH] CIMI - slight hack to prefer content_type of xml when CIMI frontend is being used (and client specifies this as accepted type) From: David Lutterkort To: dev@deltacloud.apache.org Date: Tue, 13 Mar 2012 14:11:12 -0700 In-Reply-To: <1331655434-19954-1-git-send-email-marios@redhat.com> References: <1331655434-19954-1-git-send-email-marios@redhat.com> Organization: Red Hat Inc Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Virus-Checked: Checked by ClamAV on apache.org On Tue, 2012-03-13 at 18:17 +0200, marios@redhat.com wrote: > From: marios > > HTML views for CIMI are being phased out... > > Signed-off-by: marios > --- > server/lib/sinatra/rack_accept.rb | 10 +++++++--- > 1 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/server/lib/sinatra/rack_accept.rb b/server/lib/sinatra/rack_accept.rb > index b576307..0f179ea 100644 > --- a/server/lib/sinatra/rack_accept.rb > +++ b/server/lib/sinatra/rack_accept.rb > @@ -77,9 +77,13 @@ module Rack > self[type] = handler > end > yield wants > - @media_type = accepting_formats.to_a.sort { |a,b| a[1]<=>b[1] }.reverse.select do |format, priority| > - wants.keys.include?(format) == true > - end.first > + if ENV['API_FRONTEND'] == "cimi" > + @media_type = (accepting_formats.has_key?(:xml) ? [:xml, accepting_formats[:xml]] : nil) > + else > + @media_type ||= accepting_formats.to_a.sort { |a,b| a[1]<=>b[1] }.reverse.select do |format, priority| > + wants.keys.include?(format) == true > + end.first > + end Doesn't this break content negotiation ? We can only ignore other formats if q=1 for application/xml (implicitly or explicitly) In particular, wouldn't the above break with an Accept header of 'application/json, application/xml;q=0.9' ? Also, it would be cleaner if the format preference was encoded in each server.rb (e.g., as an array constant) AFAIK, self at this point is the Sinatra app. David