Accessing response header from xform-submission

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing response header from xform-submission

pappleby
I would like to access the HTTP headers that from the response for an xforms:submission to eXist.

The processor details are below ...

I found an earlier post that mentioned using xforms:insert and event('response-headers') but I'm struggling to see how to implement that, and access the output, from within the processor/pipeline.

Any help welcome.

Thanks

Paul

<p:processor name="oxf:xforms-submission">
        <p:input name="submission">
                <xforms:submission method="get" action="http://localhost:8088/db/queries/legislation.xq" separator="&amp;"/>
        </p:input>
        <p:input name="request" href="#instance" transform="oxf:xslt">
                <parameters xsl:version="2.0">
                        <xsl:sequence select="/parameters/type" />
                        <year>
                                <xsl:choose>
                                        <xsl:when test="/parameters/monarch != ''">
                                                <xsl:value-of select="/parameters/monarch" />_<xsl:value-of select="/parameters/year" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                                <xsl:value-of select="/parameters/year" />
                                        </xsl:otherwise>
                                </xsl:choose>
                        </year>
                        <xsl:sequence select="/parameters/number" />
                </parameters>
        </p:input>
        <p:output name="response" id="xmlData" />
</p:processor>

Reply | Threaded
Open this post in threaded view
|

Re: Accessing response header from xform-submission

Alessandro Vernet
Administrator
Paul,

Paul Appleby wrote
I would like to access the HTTP headers that from the response for an xforms:submission to eXist.

The processor details are below ...

I found an earlier post that mentioned using xforms:insert and event('response-headers') but I'm struggling to see how to implement that, and access the output, from within the processor/pipeline.
I think you'll be able to use event('response-headers') on xforms-submit-done, and then you can maybe insert an element to the result that contains a the value for the header your are interested in. Something like:

<xforms:submission method="get" action="http://localhost:8088/db/queries/legislation.xq" separator="&amp;">
    <xforms:action ev:event="xforms-submit-done">
        <xforms:insert context="." origin="xxforms:element('gaga', event('response-headers')[name = 'gaga']/value)"/>
    </xforms:action>
</xforms:submission>

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Accessing response header from xform-submission

pappleby
That worked fine, many thanks.

Although ... it's a little cumbersome having to insert the information into the response. It would be better to be able to pick it up separately - but I can certainly work with it as is.

Paul

Alessandro Vernet wrote
Paul,

Paul Appleby wrote
I would like to access the HTTP headers that from the response for an xforms:submission to eXist.

The processor details are below ...

I found an earlier post that mentioned using xforms:insert and event('response-headers') but I'm struggling to see how to implement that, and access the output, from within the processor/pipeline.
I think you'll be able to use event('response-headers') on xforms-submit-done, and then you can maybe insert an element to the result that contains a the value for the header your are interested in. Something like:

<xforms:submission method="get" action="http://localhost:8088/db/queries/legislation.xq" separator="&amp;">
    <xforms:action ev:event="xforms-submit-done">
        <xforms:insert context="." origin="xxforms:element('gaga', event('response-headers')[name = 'gaga']/value)"/>
    </xforms:action>
</xforms:submission>

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Accessing response header from xform-submission

Alessandro Vernet
Administrator
Paul,

Paul Appleby wrote
Although ... it's a little cumbersome having to insert the information into the response. It would be better to be able to pick it up separately - but I can certainly work with it as is.
You can have a separate instance for this, where you just store the value of the headers you are interested in when you do a submission. Thinking about it, this is most likely how I would implement it.

Alex