Return-Path: X-Original-To: apmail-incubator-jena-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-jena-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D5D374CFF for ; Wed, 29 Jun 2011 19:34:56 +0000 (UTC) Received: (qmail 49723 invoked by uid 500); 29 Jun 2011 19:34:56 -0000 Delivered-To: apmail-incubator-jena-commits-archive@incubator.apache.org Received: (qmail 49700 invoked by uid 500); 29 Jun 2011 19:34:56 -0000 Mailing-List: contact jena-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-dev@incubator.apache.org Delivered-To: mailing list jena-commits@incubator.apache.org Received: (qmail 49693 invoked by uid 99); 29 Jun 2011 19:34:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jun 2011 19:34:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jun 2011 19:34:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9F2002388994; Wed, 29 Jun 2011 19:34:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1141212 - in /incubator/jena/Jena2/Fuseki/trunk: src-dev/dev/ src/main/java/org/openjena/fuseki/conneg/ src/main/java/org/openjena/fuseki/servlets/ Date: Wed, 29 Jun 2011 19:34:34 -0000 To: jena-commits@incubator.apache.org From: andy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110629193434.9F2002388994@eris.apache.org> Author: andy Date: Wed Jun 29 19:34:34 2011 New Revision: 1141212 URL: http://svn.apache.org/viewvc?rev=1141212&view=rev Log: Add handling of unusual multiple Accept headers Added: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/WebLib.java (with props) Modified: incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/ConNeg.java incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/ResponseQuery.java Modified: incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java?rev=1141212&r1=1141211&r2=1141212&view=diff ============================================================================== --- incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java (original) +++ incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java Wed Jun 29 19:34:34 2011 @@ -2,6 +2,10 @@ package dev; public class DevFuseki { + // Flint? + // Pages for publish mode. + + // Multiple Accept headers // WebContent and ContentType clean up. // SOH defualt to not needing 'default' Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/ConNeg.java URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/ConNeg.java?rev=1141212&r1=1141211&r2=1141212&view=diff ============================================================================== --- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/ConNeg.java (original) +++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/ConNeg.java Wed Jun 29 19:34:34 2011 @@ -8,6 +8,7 @@ package org.openjena.fuseki.conneg; import static org.openjena.fuseki.HttpNames.hAcceptCharset ; + import javax.servlet.http.HttpServletRequest ; import org.slf4j.Logger ; @@ -73,7 +74,7 @@ public class ConNeg AcceptList myPrefs, MediaType defaultMediaType) { - String a = httpRequest.getHeader("Accept") ; + String a = WebLib.getAccept(httpRequest) ; if ( log.isDebugEnabled() ) log.debug("Accept request: "+a) ; Added: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/WebLib.java URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/WebLib.java?rev=1141212&view=auto ============================================================================== --- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/WebLib.java (added) +++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/WebLib.java Wed Jun 29 19:34:34 2011 @@ -0,0 +1,76 @@ +/* + * (c) Copyright 2011 Epimorphics Ltd. + * All rights reserved. + * [See end of file] + */ + +package org.openjena.fuseki.conneg; + +import java.util.Enumeration ; + +import javax.servlet.http.HttpServletRequest ; + +import org.openjena.fuseki.HttpNames ; + +public class WebLib +{ + /** Split a string, removing whitespace around the split string. + * e.g. Use in splittign HTTP accept/content-type headers. + */ + public static String[] split(String s, String splitStr) + { + String[] x = s.split(splitStr,2) ; + for ( int i = 0 ; i < x.length ; i++ ) + { + x[i] = x[i].trim() ; + } + return x ; + } + + /** Migrate to WebLib */ + public static String getAccept(HttpServletRequest httpRequest) + { + // There can be multiple accept headers -- note many tools don't allow these to be this way (e.g. wget, curl) + @SuppressWarnings("unchecked") + Enumeration en = httpRequest.getHeaders(HttpNames.hAccept) ; + if ( ! en.hasMoreElements() ) + return null ; + StringBuilder sb = new StringBuilder() ; + String sep = "" ; + for ( ; en.hasMoreElements() ; ) + { + String x = en.nextElement() ; + sb.append(sep) ; + sep = ", " ; + sb.append(x) ; + } + return sb.toString() ; + } +} + +/* + * (c) Copyright 2011 Epimorphics Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ \ No newline at end of file Propchange: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/conneg/WebLib.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/ResponseQuery.java URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/ResponseQuery.java?rev=1141212&r1=1141211&r2=1141212&view=diff ============================================================================== --- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/ResponseQuery.java (original) +++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/ResponseQuery.java Wed Jun 29 19:34:34 2011 @@ -21,6 +21,7 @@ import org.openjena.fuseki.conneg.Accept import org.openjena.fuseki.conneg.ConNeg ; import org.openjena.fuseki.conneg.MediaType ; import org.openjena.fuseki.conneg.TypedInputStream ; +import org.openjena.fuseki.conneg.WebLib ; import org.openjena.fuseki.http.HttpSC ; import org.openjena.riot.Lang ; import org.openjena.riot.WebContent ; @@ -57,7 +58,7 @@ public class ResponseQuery if ( mimeType == null ) { Fuseki.requestLog.warn("Can't find MIME type for response") ; - String x = request.getHeader("Accept") ; + String x = WebLib.getAccept(request) ; String msg ; if ( x == null ) msg = "No Accept: header" ; @@ -360,7 +361,7 @@ public class ResponseQuery private static String paramAcceptField(HttpServletRequest request) { - String acceptField = request.getHeader(HttpNames.hAccept) ; + String acceptField = WebLib.getAccept(request) ; String acceptParam = fetchParam(request, HttpNames.paramAccept) ; if ( acceptParam != null )