I noticed that Batik doesn't send any Accept headers (or wrong ones) in the HTTP requests. I added them in the 1.0 version (see attachments). Note: - Didn't do anything about Accept-Language yet. - the charset parameter is valid for text/xml and application/xml. Don't know about image/svg+xml. - I also added the User-Agent header. Philippe
Index: sources/org/apache/batik/ext/awt/image/ImageLoader.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/ext/awt/image/ImageLoader.java,v retrieving revision 1.1 diff -r1.1 ImageLoader.java 22c22,24 < public class ImageLoader { --- > import org.apache.batik.util.HTTPConstants; > > public class ImageLoader implements HTTPConstants { 185c190,201 < in = url.openStream(); --- > URLConnection urlC = url.openConnection(); > > if (urlC instanceof HttpURLConnection) { > urlC.setRequestProperty(HTTP_USER_AGENT_HEADER, > HTTP_BATIK_USER_AGENT); > urlC.setRequestProperty(HTTP_ACCEPT_HEADER, > HTTP_ACCEPT_JPEG); > } > > urlC.connect(); > > in = urlC.getInputStream();
Index: sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v retrieving revision 1.44 diff -r1.44 JSVGViewerFrame.java 47a48,49 > import java.net.URLConnection; > import java.net.HttpURLConnection; 108a111 > import org.apache.batik.util.HTTPConstants; 140a144 > HTTPConstants, 1037a1042,1051 > URLConnection urlC = u.openConnection(); > > if (urlC instanceof HttpURLConnection) { > urlC.setRequestProperty(HTTP_USER_AGENT_HEADER, > HTTP_BATIK_USER_AGENT); > urlC.setRequestProperty(HTTP_ACCEPT_HEADER, > HTTP_ACCEPT_SVG); > } > > urlC.connect(); 1039c1053,1054 < InputStream is = ParsedURL.checkGZIP(u.openStream()); --- > InputStream is = > ParsedURL.checkGZIP(urlC.getInputStream());
Index: sources/org/apache/batik/util/ParsedURLData.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/util/ParsedURLData.java,v retrieving revision 1.1 diff -r1.1 ParsedURLData.java 14a15,16 > import java.net.URLConnection; > import java.net.HttpURLConnection; 19c21,23 < public class ParsedURLData { --- > import org.apache.batik.util.HTTPConstants; > > public class ParsedURLData implements HTTPConstants { 232c236,251 < return url.openStream(); --- > > URLConnection urlC = url.openConnection(); > > if (urlC instanceof HttpURLConnection) { > urlC.setRequestProperty(HTTP_USER_AGENT_HEADER, > HTTP_BATIK_USER_AGENT); > urlC.setRequestProperty(HTTP_ACCEPT_HEADER, > HTTP_ACCEPT_PNG + "," > + HTTP_ACCEPT_JPEG + "," > + HTTP_ACCEPT_GIF + "," > + HTTP_ACCEPT_TIFF); > } > > urlC.connect(); > > return urlC.getInputStream();
Index: sources/org/apache/batik/css/parser/Parser.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/css/parser/Parser.java,v retrieving revision 1.10 diff -r1.10 Parser.java 18a19,20 > import java.net.URLConnection; > import java.net.HttpURLConnection; 28a31 > import org.apache.batik.util.HTTPConstants; 51a55 > HTTPConstants, 1536c1540,1553 < return characterStream(source, url.openStream(), enc); --- > URLConnection urlC = url.openConnection(); > > if (urlC instanceof HttpURLConnection) { > urlC.setRequestProperty(HTTP_USER_AGENT_HEADER, > HTTP_BATIK_USER_AGENT); > urlC.setRequestProperty(HTTP_ACCEPT_HEADER, > HTTP_ACCEPT_CSS); > } > > urlC.connect(); > > // Don't disconnect the connection to allow persistent > // connection. > return characterStream(source, urlC.getInputStream(), enc);
Index: sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java,v retrieving revision 1.8 diff -r1.8 SAXSVGDocumentFactory.java 11a12 > import java.io.BufferedInputStream; 16a18,19 > import java.net.URLConnection; > import java.net.HttpURLConnection; 23a27,28 > import org.apache.batik.util.HTTPConstants; > 41c46,47 < implements SVGDocumentFactory { --- > implements SVGDocumentFactory, > HTTPConstants { 78a85,86 > URLConnection urlC; > 85c93,109 < InputStream is = url.openStream(); --- > urlC = url.openConnection(); > > if (urlC instanceof HttpURLConnection) { > // no constant for Batik version?!? > urlC.setRequestProperty(HTTP_USER_AGENT_HEADER, > HTTP_BATIK_USER_AGENT); > // this is a CSS parser, only accept the CSS mime type > urlC.setRequestProperty(HTTP_ACCEPT_HEADER, > HTTP_ACCEPT_SVG); > } > > urlC.connect(); > > InputStream is = urlC.getInputStream(); > if (!is.markSupported()) { > is = new BufferedInputStream(is, 4096); > } 86a111 > is.mark(16); 89,90c114 < is.close(); < is = url.openStream(); --- > is.reset(); 94a119,144 > > // now looking for a charset encoding in the content type > // such as "image/svg+xml; charset=iso8859-1" > // this is not official for image/svg+xml yet! only for text/xml and maybe > // for application/xml > String contentType = urlC.getContentType(); > int cindex = (contentType == null)? > -1 > : contentType.indexOf(HTTP_CHARSET); > > if (cindex != -1) { > StringBuffer bcharset = new StringBuffer(10); > int length = contentType.length(); > int i = cindex + HTTP_CHARSET.length(); > while ((i < length) && (contentType.charAt(i) != '=')) { > i ++; > } > if (++i < length) { > char c; > while ((i < length) && ((c = contentType.charAt(i)) != ',')) { > bcharset.append(c); > i ++; > } > isrc.setEncoding(bcharset.toString().trim()); > } > }
/***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.util; /** * Contains useful HTTP Headers used for HTTP requests. */ public interface HTTPConstants { String HTTP_ACCEPT_HEADER = "Accept"; String HTTP_ACCEPT_LANGUAGE_HEADER = "Accept-Language"; String HTTP_USER_AGENT_HEADER = "User-Agent"; String HTTP_CHARSET = "charset"; String HTTP_BATIK_USER_AGENT = "Batik/1.0"; String HTTP_ACCEPT_JPEG = "image/jpeg"; String HTTP_ACCEPT_GIF = "image/gif"; String HTTP_ACCEPT_PNG = "image/png"; String HTTP_ACCEPT_TIFF = "image/tiff"; String HTTP_ACCEPT_CSS = "text/css"; String HTTP_ACCEPT_SVG = "image/svg+xml,application/xml,text/xml"; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]