Skip to content

Instantly share code, notes, and snippets.

@gimsieke
Created February 1, 2016 20:41
Show Gist options
  • Save gimsieke/c456c5f82a346c515960 to your computer and use it in GitHub Desktop.
Save gimsieke/c456c5f82a346c515960 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
<p:documentation>Checks the availability of a resource given in the href option.
URL that works (HTTP status 200): http://www.le-tex.de/
URL that is unavailable (404): http://www.le-tex.de/foo
URL that causes an error that is caught: http://www.le-tex
URL that causes an uncaught exception: http://www.journalofosteopathicmedicine.com/
ERROR: org.apache.http.client.ClientProtocolException
ERROR: Underlying exception: null
After digging a bit, @lwittmar got hold of the root cause:
Caused by: org.apache.http.client.CircularRedirectException:
Circular redirect to 'http://www.journalofosteopathicmedicine.com/action/consumeSharedSessionAction?JSESSIONID=…'
</p:documentation>
<p:option name="href">
<p:documentation>URL to check</p:documentation>
</p:option>
<p:output port="result" primary="true"/>
<p:add-attribute name="create-request" match="/*" attribute-name="href">
<p:input port="source">
<p:inline>
<c:request method="head" detailed="true" status-only="true"/>
</p:inline>
</p:input>
<p:with-option name="attribute-value" select="$href"/>
</p:add-attribute>
<p:try name="send-request">
<p:group>
<p:http-request/>
</p:group>
<p:catch name="catch">
<p:identity>
<p:input port="source">
<p:pipe port="error" step="catch"/>
</p:input>
</p:identity>
</p:catch>
</p:try>
</p:declare-step>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment