p:http-request 131 (NW)
Only follow the first follow-redirect redirections.
Test is expected to pass.
The pipeline
<p:declare-step xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-inline-prefixes="c xs"
version="3.0">
<p:output port="result"/>
<p:option name="WHOST"
select="'http://localhost:8246'" static="true"/>
<p:http-request method="get"
href="{$WHOST}/service/this-is-a"
parameters="map{'follow-redirect': 2}">
<p:with-input>
<p:empty/>
</p:with-input>
</p:http-request>
<p:identity>
<p:with-input pipe="report"/>
</p:identity>
<p:identity name="status">
<p:with-input>
<code>{.?status-code}</code>
<base-uri>{.?base-uri}</base-uri>
<location>{.?headers?location}</location>
</p:with-input>
</p:identity>
<p:wrap-sequence wrapper="wrap"/>
</p:declare-step>
Result
<wrap xmlns:t="http://xproc.org/ns/testsuite/3.0">
<code xmlns:err="http://www.w3.org/ns/xproc-error">302</code>
<base-uri xmlns:err="http://www.w3.org/ns/xproc-error">http://apache2/service/this-is-c</base-uri>
<location xmlns:err="http://www.w3.org/ns/xproc-error">http://apache2/service/this-is-d</location>
</wrap>
Schematron checks
<s:schema xmlns="http://www.w3.org/1999/xhtml"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:t="http://xproc.org/ns/testsuite/3.0"
queryBinding="xslt2">
<s:ns prefix="p" uri="http://www.w3.org/ns/xproc"/>
<s:ns prefix="c"
uri="http://www.w3.org/ns/xproc-step"/>
<s:pattern>
<s:rule context="/*">
<s:assert test="self::wrap">The root is not wrap.</s:assert>
<s:assert test="ends-with(base-uri, '/service/this-is-c')">The base-uri is incorrect.</s:assert>
<s:assert test="code = 302">The status-code is incorrect.</s:assert>
<s:assert test="ends-with(location, '/service/this-is-d')">The redirect location is incorrect.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 23 May 2025, Norm Tovey-Walsh
- Added static options for web server host and port.
- 10 Sep 2021, Norman Walsh
- Reworked the test. A redirect no longer returns a document, so
there’s no base URI. Instead, the test assumes the base URI will be in the
map produced on the report port.
- 09 Sep 2021, Norman Walsh
- Test that follow-redirect works as advertised.