Features: p:http-request

p:http-request 128 (NW)

If the documents in a mulitpart request have document properties in the http://www.w3.org/ns/xproc-http namespace, those properties become headers.

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:option name="WHOST"
             select="'http://localhost:8246'" static="true"/>
   <p:output port="result"/>
   <p:http-request xmlns:chttp="http://www.w3.org/ns/xproc-http"
                   href="{$WHOST}/service/check-multipart" method="post">
      <p:with-input>
         <p:inline document-properties="map{                    'chttp:content-id': 'abcdefg',                    'chttp:content-description': 'First document'                 }">
            <doc1/>
         </p:inline>
         <p:inline document-properties="map{                    'chttp:content-description': 'Second document',                    'chttp:content-disposition': 'attachment; filename=abc.xml',                    'chttp:random-header': 'value'                 }">
            <doc2/>
         </p:inline>
      </p:with-input>
   </p:http-request>
</p:declare-step>

Result

<check-multipart xmlns:t="http://xproc.org/ns/testsuite/3.0"
                 method="POST"
                 boundary="B34833121-9395-4979-a6f5-5ab857a991ea" content-type="multipart/mixed">
   <header name="accept_encoding">gzip, x-gzip, deflate, br</header>
   <part>
      <header name="content-description">First document</header>
      <header name="Content-Disposition">attachment</header>
      <header name="content-id">abcdefg</header>
      <header name="Content-Type">application/xml; charset=UTF-8</header>
      <body xml-declaration='xml version="1.0" encoding="UTF-8"'>
         <doc1 xmlns:chttp="http://www.w3.org/ns/xproc-http"
               xmlns:err="http://www.w3.org/ns/xproc-error"/>
      </body>
   </part>
   <part>
      <header name="content-description">Second document</header>
      <header name="content-disposition">attachment; filename=abc.xml</header>
      <header name="Content-Type">application/xml; charset=UTF-8</header>
      <header name="random-header">value</header>
      <body xml-declaration='xml version="1.0" encoding="UTF-8"'>
         <doc2 xmlns:chttp="http://www.w3.org/ns/xproc-http"
               xmlns:err="http://www.w3.org/ns/xproc-error"/>
      </body>
   </part>
</check-multipart>

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::check-multipart">The root is not check-multipart.</s:assert>
         <s:assert test="part[1]/header[lower-case(@name) = 'content-description'] = 'First document'">The content-description of the first part is incorrect.</s:assert>
         <s:assert test="part[1]/header[lower-case(@name) = 'content-id'] = 'abcdefg'">The content-id of the first part is incorrect.</s:assert>
         <s:assert test="part[2]/header[lower-case(@name) = 'content-description'] = 'Second document'">The content-description of the second part is incorrect.</s:assert>
         <s:assert test="part[2]/header[lower-case(@name) = 'content-disposition']                 = 'attachment; filename=abc.xml'">The content-disposition of the second part is incorrect.</s:assert>
         <s:assert test="part[2]/header[lower-case(@name) = 'random-header'] = 'value'">The random-header of the second part 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.
09 Sep 2021, Norman Walsh
Check that xproc-http properties become headers in multipart documents.