Re: Xalan handling of HTTP redirects by the document() method

Dennis van der Laan <[email protected]> Wed, 6 Jan 2016 15:55:54 +0100
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <CAGpcBSLn8WjM-ijjPXAxtX=HPxytojfHiTjLG7+UxJ37r98CPQ@mail.gmail.com>
--001a114d7484104cc80528ab8dcc
Content-Type: text/plain; charset=UTF-8

Hi sebb,

Don't know if this is answered yet, but I guess Xalan uses the java
standard HttpURLConnection to get the contents as an inputstream. The
HttpURLConnection class has a static method 'setFollowRedirects(boolean)',
which enables or disables redirection handling for all HttpURLConnections
in your JVM. There might be some code that disables this (the default is
'true'). If enabling redirection handling breaks your code, you might want
to override the URIResolver for your transformations. In that case, you can
implement how external contents is loaded (e.g. you can add caching of
resources, etc). Be aware that the URIResolver also handles includes and
imports, not only the document() function.
Hope this helps.
Best regards,
Dennis

On Tue, Jan 5, 2016 at 8:44 PM, sebb <[email protected]> wrote:

> I'm getting an error when using document() on a URL which redirects.
>
> It looks like Xalan (2.7.2) is not honouring the redirect, but instead
> is processing the content.
>
> Is this a known restriction?
>
> Is there a way to tell Xalan to honour redirects when processing
> document() calls?
>



-- 
D.G. van der Laan, MSc
Sr. Software Engineer, Center for Information Technology
+31 (0)50 363 9273

--001a114d7484104cc80528ab8dcc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:arial,he=
lvetica,sans-serif">Hi sebb,</div><div class=3D"gmail_default" style=3D"fon=
t-family:arial,helvetica,sans-serif"><br></div><div class=3D"gmail_default"=
 style=3D"font-family:arial,helvetica,sans-serif">Don&#39;t know if this is=
 answered yet, but I guess Xalan uses the java standard HttpURLConnection t=
o get the contents as an inputstream. The HttpURLConnection class has a sta=
tic method &#39;setFollowRedirects(boolean)&#39;, which enables or disables=
 redirection handling for all HttpURLConnections in your JVM. There might b=
e some code that disables this (the default is &#39;true&#39;). If enabling=
 redirection handling breaks your code, you might want to override the URIR=
esolver for your transformations. In that case, you can implement how exter=
nal contents is loaded (e.g. you can add caching of resources, etc). Be awa=
re that the URIResolver also handles includes and imports, not only the doc=
ument() function.</div><div class=3D"gmail_default" style=3D"font-family:ar=
ial,helvetica,sans-serif">Hope this helps.</div><div class=3D"gmail_default=
" style=3D"font-family:arial,helvetica,sans-serif">Best regards,</div><div =
class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif">De=
nnis</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">O=
n Tue, Jan 5, 2016 at 8:44 PM, sebb <span dir=3D"ltr">&lt;<a href=3D"mailto=
:[email protected]" target=3D"_blank">[email protected]</a>&gt;</span> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">I&#39;m getting an error when using docu=
ment() on a URL which redirects.<br>
<br>
It looks like Xalan (2.7.2) is not honouring the redirect, but instead<br>
is processing the content.<br>
<br>
Is this a known restriction?<br>
<br>
Is there a way to tell Xalan to honour redirects when processing<br>
document() calls?<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class=
=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div><div>=
<div><div><div><div></div><font color=3D"#cc0000" size=3D"1"><font face=3D"=
georgia,serif">D.G. van der Laan, MSc<br></font></font></div><font color=3D=
"#cc0000" size=3D"1"><font face=3D"georgia,serif">Sr. Software Engineer, Ce=
nter for Information Technology<br>+31 (0)50 363 9273</font></font><br></di=
v></div></div></div></div><img src=3D"https://docs.google.com/uc?export=3Dd=
ownload&amp;id=3D0B_7z4ALsPMAMNnBBQVZJOVd1RWM&amp;revid=3D0B_7z4ALsPMAMenM3=
MEM4akF3bGN2N25qWWhIYWF6MC9BSVM0PQ"><br></div></div></div></div>
</div>

--001a114d7484104cc80528ab8dcc--