Topic
5 replies Latest Post - ‏2013-05-04T19:13:12Z by jimcpl
jimcpl
jimcpl
6 Posts
ACCEPTED ANSWER

Pinned topic How to send incoming HTTP header in response in loopback?

‏2013-05-02T19:35:47Z |

Hi,

It's been several years since I've worked with the XI50 (and now, the XG45), so I'm starting from scratch with a simple scenario, where I have an XML gateway that is configured for loopback.  I have enabled it to receive HTTP GETs, so I can test using a browser like Firefox.

I've created the XML gateway, but now, I'd like to have it take an incoming HTTP header named "fooheader" and send that back out to the client in the response.

Can someone tell me how to do that?

Thanks,

Jim

  • kenhygh
    kenhygh
    1306 Posts
    ACCEPTED ANSWER

    Re: How to send incoming HTTP header in response in loopback?

    ‏2013-05-02T21:14:01Z  in response to jimcpl

    There's an extension function to get the request header, and an extension element to set a response header.

     

    Ken

    • jimcpl
      jimcpl
      6 Posts
      ACCEPTED ANSWER

      Re: How to send incoming HTTP header in response in loopback?

      ‏2013-05-02T21:35:07Z  in response to kenhygh

      What is the extension function to get the request header?

       

      Also, I may've been unclear as far as the response.  I want the contents of the request header to appear in the response itself, not in a response header.

       

      Thanks,

      Jim

      • jimcpl
        jimcpl
        6 Posts
        ACCEPTED ANSWER

        Re: How to send incoming HTTP header in response in loopback?

        ‏2013-05-02T21:38:30Z  in response to jimcpl

        Hi,

         

        I was wondering if it'd be possible to post a small complete XSLT that would do that (pull the HTTP header contents from the request, and then include that in the response)?  Something that could be run in a Transform action?

         

        Thanks,

        Jim

        • RolfRander
          RolfRander
          23 Posts
          ACCEPTED ANSWER

          Re: How to send incoming HTTP header in response in loopback?

          ‏2013-05-04T13:21:20Z  in response to jimcpl
          <?xml version="1.0" encoding="UTF-8"?>
          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:dp="http://www.datapower.com/extensions"
             extension-element-prefixes="dp">
           
             <xsl:template match="/">
               <http-headers>
                  <accept><xsl:value-of select="dp:http-request-header('Accept')"/></accept>
                  <cache-control><xsl:value-of select="dp:http-request-header('Cache-Control')"/></cache-control>
                  <connection><xsl:value-of select="dp:http-request-header('Connection')"/></connection>                   
                  <content-type><xsl:value-of select="dp:http-request-header('Content-Type')"/></content-type>
                  <host><xsl:value-of select="dp:http-request-header('Host')"/></host>
               </http-headers>
             </xsl:template>
          </xsl:stylesheet>

           

          Regards, rolf rander
          Updated on 2013-05-04T13:25:38Z at 2013-05-04T13:25:38Z by RolfRander
          • jimcpl
            jimcpl
            6 Posts
            ACCEPTED ANSWER

            Re: How to send incoming HTTP header in response in loopback?

            ‏2013-05-04T19:13:12Z  in response to RolfRander

            Rolf,

             

            Thanks!

             

            Jim