Topic
  • 15 replies
  • Latest Post - ‏2014-07-17T20:09:08Z by kenhygh
nepomuk
nepomuk
160 Posts

Pinned topic Removing Content-Type from http header

‏2013-07-15T15:17:19Z |

I am processing REST GET and DELETE calls and need to remove Content-Type from the http header. But every time I delete it Datapower puts it back at the end of the rule.

Anyone know how I can delete it from a request?

  • Miel
    Miel
    50 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-15T17:58:51Z  

    Hi,

                         Delete the HTTP content type header after the result action of your rule or remove the result action from the rule.

    Result action will automatically add the default content type header.

  • JTQK_Sunny_Goel
    JTQK_Sunny_Goel
    10 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-23T21:09:12Z  
    • Miel
    • ‏2013-07-15T17:58:51Z

    Hi,

                         Delete the HTTP content type header after the result action of your rule or remove the result action from the rule.

    Result action will automatically add the default content type header.

    Hi Miel,

    I tried following methods but nothing worked for "Content-Type" http header. Please help us in resolving this problem.

    1.) Used following code in xslt and removed result action from request rule.

    2.) Used following code in xslt after result action.

    <dp:remove-http-request-header name="Content-Type"/>

    Thanks

     

     


     

     

  • Miel
    Miel
    50 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-24T04:35:26Z  

    Hi Miel,

    I tried following methods but nothing worked for "Content-Type" http header. Please help us in resolving this problem.

    1.) Used following code in xslt and removed result action from request rule.

    2.) Used following code in xslt after result action.

    <dp:remove-http-request-header name="Content-Type"/>

    Thanks

     

     


     

     

    Hi,

       Try with suppression headers. go to header tab of your service and configure the suppression header (back or front ), it will remove the mentioned headers before forwarding the request to the backend server.

     

  • JTQK_Sunny_Goel
    JTQK_Sunny_Goel
    10 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-24T19:02:38Z  
    • Miel
    • ‏2013-07-24T04:35:26Z

    Hi,

       Try with suppression headers. go to header tab of your service and configure the suppression header (back or front ), it will remove the mentioned headers before forwarding the request to the backend server.

     

    Hi Miel,

    I tried suppressing following HTTP headers using "Headers/Params" tab of web service proxy service. But i was able to suppress only 1 header and that is "Content-Length". I am assuming we cann't suppress other headers. Service adds these headers before forwarding request to backend.

     

    HTTP headers

    X-Client-IP,Content-Type and Content-Length

    Thank you

     

     

     

  • HermannSW
    HermannSW
    6645 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-24T20:13:50Z  

    Hi Miel,

    I tried suppressing following HTTP headers using "Headers/Params" tab of web service proxy service. But i was able to suppress only 1 header and that is "Content-Length". I am assuming we cann't suppress other headers. Service adds these headers before forwarding request to backend.

     

    HTTP headers

    X-Client-IP,Content-Type and Content-Length

    Thank you

     

     

     

    The spec defines HTTP header entries here:
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    I did add header suppresions for the following fields on MPGW's Headers tab.
    The MPGW was a XML request, with Process Empty Messages On and pass-thru response service.
    Backend was a passthru loopback XML FW on same box.

    That way sending GET request by "curl ... -v" returns all the headers send to "backend" in curl response.

    These "back" suppressions did not have an effect:

    The Via general-header field MUST be used by gateways and proxies
    The Transfer-Encoding general-header field
    The Content-Type entity-header fiel
    The Connection general-header field
    The Cache-Control general-header

    And this does not have an effect (because of the MUST from spec)

    The Host request-header field ... A client MUST include a Host header field in all HTTP/1.1 request messages .

    This one got removed successfully:

    The User-Agent request-header field

     

    So it seems that you cannot suppress "general-header", "entity-header" and some special "request-header" fields.

    But you can suppress "request-header" fields normally.

     

    Trying to get someone to comment on this who knows more than me on this ...

     

     

    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>



     

    Updated on 2013-07-24T20:16:39Z at 2013-07-24T20:16:39Z by HermannSW
  • Miel
    Miel
    50 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-25T05:29:45Z  
    • HermannSW
    • ‏2013-07-24T20:13:50Z

    The spec defines HTTP header entries here:
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    I did add header suppresions for the following fields on MPGW's Headers tab.
    The MPGW was a XML request, with Process Empty Messages On and pass-thru response service.
    Backend was a passthru loopback XML FW on same box.

    That way sending GET request by "curl ... -v" returns all the headers send to "backend" in curl response.

    These "back" suppressions did not have an effect:

    The Via general-header field MUST be used by gateways and proxies
    The Transfer-Encoding general-header field
    The Content-Type entity-header fiel
    The Connection general-header field
    The Cache-Control general-header

    And this does not have an effect (because of the MUST from spec)

    The Host request-header field ... A client MUST include a Host header field in all HTTP/1.1 request messages .

    This one got removed successfully:

    The User-Agent request-header field

     

    So it seems that you cannot suppress "general-header", "entity-header" and some special "request-header" fields.

    But you can suppress "request-header" fields normally.

     

    Trying to get someone to comment on this who knows more than me on this ...

     

     

    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>



     

    Hi Hermann,

                 I agreed your statement, looks like we can't suppress "general-header","entity-header" using the suppression header option.

  • Miel
    Miel
    50 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-26T05:50:26Z  

    Hi Miel,

    I tried following methods but nothing worked for "Content-Type" http header. Please help us in resolving this problem.

    1.) Used following code in xslt and removed result action from request rule.

    2.) Used following code in xslt after result action.

    <dp:remove-http-request-header name="Content-Type"/>

    Thanks

     

     


     

     

    Hi,

          After removing the Content-Type header , freeze the headers using dp element called <dp:freeze-headers/>.It works charm

                        <dp:remove-http-request-header name="Content-Type"/>

                        <dp:freeze-headers/>

     

    Regards,

    Miel.

  • srinivasdp
    srinivasdp
    1 Post

    Re: Removing Content-Type from http header

    ‏2013-07-26T11:15:01Z  
    • Miel
    • ‏2013-07-26T05:50:26Z

    Hi,

          After removing the Content-Type header , freeze the headers using dp element called <dp:freeze-headers/>.It works charm

                        <dp:remove-http-request-header name="Content-Type"/>

                        <dp:freeze-headers/>

     

    Regards,

    Miel.

    Hi

    This is srinivas, i am a new datapower developer,please any one  post some importent dp functions and explain.

     

    Regards

    srinivas

     

  • David07
    David07
    79 Posts

    Re: Removing Content-Type from http header

    ‏2013-07-26T11:59:14Z  

    Hi

    This is srinivas, i am a new datapower developer,please any one  post some importent dp functions and explain.

     

    Regards

    srinivas

     

    Hi,

    Please go through the below mentioned link, every dp function is explained clearly. You will get an idea about it.

    http://publib.boulder.ibm.com/infocenter/wsdatap/v3r8m1/index.jsp?topic=%2Fxa35%2Fextensionfunctions.htm

     

    Regards,

    David.

  • Rikosito
    Rikosito
    1 Post

    Re: Removing Content-Type from http header

    ‏2013-12-06T08:36:24Z  
    • Miel
    • ‏2013-07-26T05:50:26Z

    Hi,

          After removing the Content-Type header , freeze the headers using dp element called <dp:freeze-headers/>.It works charm

                        <dp:remove-http-request-header name="Content-Type"/>

                        <dp:freeze-headers/>

     

    Regards,

    Miel.

    Thank you Miel,

    It's really work charm.

    Here you are .xsl transformation for removing Contetn-Type:

    <?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="/">
    <dp:remove-http-request-header name="Content-Type"/>
    <dp:freeze-headers/>
    </xsl:template>
    </xsl:stylesheet>
  • dapi7
    dapi7
    67 Posts

    Re: Removing Content-Type from http header

    ‏2014-07-17T11:05:42Z  
    • Rikosito
    • ‏2013-12-06T08:36:24Z

    Thank you Miel,

    It's really work charm.

    Here you are .xsl transformation for removing Contetn-Type:

    <?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="/">
    <dp:remove-http-request-header name="Content-Type"/>
    <dp:freeze-headers/>
    </xsl:template>
    </xsl:stylesheet>

    Hi.. 

    I am trying to remove the header(name="addHeader")that was added using the "append-request-header" element.

    I tried using above code but didn't work to me i.e

    <?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="/">
    <dp:remove-http-request-header name="addHeader"/>
    <dp:freeze-headers/>
    </xsl:template>
    </xsl:stylesheet>

     

    can anyone know how I can remove the header?

     

    Thanks

     

  • HermannSW
    HermannSW
    6645 Posts

    Re: Removing Content-Type from http header

    ‏2014-07-17T11:56:21Z  
    • dapi7
    • ‏2014-07-17T11:05:42Z

    Hi.. 

    I am trying to remove the header(name="addHeader")that was added using the "append-request-header" element.

    I tried using above code but didn't work to me i.e

    <?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="/">
    <dp:remove-http-request-header name="addHeader"/>
    <dp:freeze-headers/>
    </xsl:template>
    </xsl:stylesheet>

     

    can anyone know how I can remove the header?

     

    Thanks

     

    For the HTTP protocol there is dp:remove-http-requst-header(), but that will work only in request rule.

    Do you want to remove that header on response rule?
    If so, please use remove-http-response-header.

    If you use non-HTTP protocol (like MQ), you might try  set-request/response-header with empty value string.


    Hermann.

  • dapi7
    dapi7
    67 Posts

    Re: Removing Content-Type from http header

    ‏2014-07-17T12:22:28Z  
    • HermannSW
    • ‏2014-07-17T11:56:21Z

    For the HTTP protocol there is dp:remove-http-requst-header(), but that will work only in request rule.

    Do you want to remove that header on response rule?
    If so, please use remove-http-response-header.

    If you use non-HTTP protocol (like MQ), you might try  set-request/response-header with empty value string.


    Hermann.

    Hi Herman,

    I have used "xsl:dp:remove-http-requst-header("hedaerName") /> ". but didn't work.

    Also tried using <xsl:variabe name="removeHeader" select="dp:remove-http-requst-header('hedaerName')" /> , it also didn't work.

    Thanks.

  • buddhala
    buddhala
    19 Posts

    Re: Removing Content-Type from http header

    ‏2014-07-17T19:38:43Z  
    • dapi7
    • ‏2014-07-17T12:22:28Z

    Hi Herman,

    I have used "xsl:dp:remove-http-requst-header("hedaerName") /> ". but didn't work.

    Also tried using <xsl:variabe name="removeHeader" select="dp:remove-http-requst-header('hedaerName')" /> , it also didn't work.

    Thanks.

    Hi..

    This is very very urgent requirement..please respond ASAP

    I am trying to remove http headers that was added using "set-http-request-header" element.

    I am adding with following synatx:

    <xsl:variable name="header" select="'ABC'" />

    <dp:set-http-request-header name="'addHedaer'" value="$header" />

     

    Reading the header in another service using the below syntax:

    <xsl:stylesheet version="1.0" extension-element-prefixes="dp" exclude-result-prefixes="dp" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

       <xsl:template match="/">

          <xsl:variable name="getHeader" select="dp:request-header('addHeader')"/>

          <xsl:choose>

             <xsl:when test="$getHeader='ABC' ">

               <<addHeader>

                   <xsl:copy-of select="$getHeader"/>

                </addHeader>

             </xsl:when>

             <xsl:otherwise>

                <xsl:variable name="getHeader" select="'DEF'"/>

               <addHeader>

                   <xsl:copy-of select="$getHeader"/>

               </addHeader>

             </xsl:otherwise>

          </xsl:choose>

          <xsl:copy-of select="."/>

       </xsl:template>

    </xsl:stylesheet>

    In the next action I am giving he xpath for the conditional action to read the header value 

    After this I want to remove the added header below is the code 

    <dp:remove-http-requst-header("addHedaer") />

    In the response I dont want the header value to be displayed.In order to give xpath for conditional action I am displaying in reading header code but this should be removed after conditional action.

    Is there any other way to directly give the xpath of header that is added to the conditional action instead of displaying it and giving????

    Thanks!

     

     

     

  • kenhygh
    kenhygh
    2254 Posts

    Re: Removing Content-Type from http header

    ‏2014-07-17T20:09:08Z  
    • buddhala
    • ‏2014-07-17T19:38:43Z

    Hi..

    This is very very urgent requirement..please respond ASAP

    I am trying to remove http headers that was added using "set-http-request-header" element.

    I am adding with following synatx:

    <xsl:variable name="header" select="'ABC'" />

    <dp:set-http-request-header name="'addHedaer'" value="$header" />

     

    Reading the header in another service using the below syntax:

    <xsl:stylesheet version="1.0" extension-element-prefixes="dp" exclude-result-prefixes="dp" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

       <xsl:template match="/">

          <xsl:variable name="getHeader" select="dp:request-header('addHeader')"/>

          <xsl:choose>

             <xsl:when test="$getHeader='ABC' ">

               <<addHeader>

                   <xsl:copy-of select="$getHeader"/>

                </addHeader>

             </xsl:when>

             <xsl:otherwise>

                <xsl:variable name="getHeader" select="'DEF'"/>

               <addHeader>

                   <xsl:copy-of select="$getHeader"/>

               </addHeader>

             </xsl:otherwise>

          </xsl:choose>

          <xsl:copy-of select="."/>

       </xsl:template>

    </xsl:stylesheet>

    In the next action I am giving he xpath for the conditional action to read the header value 

    After this I want to remove the added header below is the code 

    <dp:remove-http-requst-header("addHedaer") />

    In the response I dont want the header value to be displayed.In order to give xpath for conditional action I am displaying in reading header code but this should be removed after conditional action.

    Is there any other way to directly give the xpath of header that is added to the conditional action instead of displaying it and giving????

    Thanks!

     

     

     

    http://pic.dhe.ibm.com/infocenter/wsdatap/v3r8m1/index.jsp?topic=%2Fxb60%2Fextensionfunctions18.htm