Exclude Server Variable from REST HTTpResponse

Exclude Server Variable from REST HTTpResponse

  

Hi,

I have REST web service exposed in outsystems. I want to remove "Server" key from HTTP response from exposed web service.  I tried to use FactoryConfiguration and created shared configuration with below xslt. 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
       
    <xsl:template match="/configuration/system.web/httpRuntime">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
            <xsl:attribute name="executionTimeout">180</xsl:attribute>
            <xsl:attribute name="maxRequestLength">65536</xsl:attribute>
        </xsl:copy>
    </xsl:template>

<xsl:template match="/configuration/system.webServer">
      <rewrite>
    <outboundRules>
      <rule name="Remove RESPONSE_Server" >
        <match serverVariable="RESPONSE_Server" pattern=".+" />
        <action type="Rewrite" value="" />
      </rule>
    </outboundRules>
  </rewrite>
       <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
 
            </xsl:copy>
    </xsl:template>

 <!--<xsl:template match="/configuration/system.webServer/httpProtocol/customHeaders">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>  
            <remove name="server"/>   --This lone of code does not remove server veriable      
           </xsl:copy>
    </xsl:template>-->
</xsl:stylesheet>


above xslt updates the web.config for my espace. I have verfied that but while publishing my espace I get the error message saying deployment failed.Could not invoke ping. Exception : underlying connection was closed at System.Net.HttpWebRequest.GetRsponse()

I am trying to rewrite Server variable value with blank instead Microsoft IIS 7.5 throgh above xslt

You can't remove or rewrite the server variable like that. It is overridden by IIS regardless of what you do at the application level.

It needs to be done outside of the application or with a rewrite module or tool.

Read this.
I don't recommend the UrlRewrite alternative ...had bad experiences with it.


Regards,
joão Rosado

João Rosado wrote:

You can't remove or rewrite the server variable like that. It is overridden by IIS regardless of what you do at the application level.

It needs to be done outside of the application or with a rewrite module or tool.

Read this.
I don't recommend the UrlRewrite alternative ...had bad experiences with it.


Regards,
joão Rosado

Thank you for your response.

Is there any way to use below .NETcode in outsystems.  Below code creates a HTTPModule which will remove server variable.

namespace StrongNamespace.HttpModules
{
  public class CustomHeaderModule : IHttpModule
  { 
    public void Init(HttpApplication context)
    {
      context.PreSendRequestHeaders += OnPreSendRequestHeaders;
    } 

    public void Dispose() { } 

    void OnPreSendRequestHeaders(object sender, EventArgs e)
    {
      HttpContext.Current.Response.Headers.Set("Server", "Box of Bolts");
    }
  }
}


I know i can write .NET extension and call it but I am not sure when I create a action in integration studio for above.NET library what would be the corresponding type for HTTPApplication object in outsystems.

Thanks,

aarti