We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

httpCompression dynamicTypes not matching the wildcard *(star) in “application/json*”RSS

1 reply

Last post Jan 30, 2016 02:39 AM by lextm

  • httpCompression dynamicTypes not matching the wildcard *(star) in “application/json*”

    Jan 29, 2016 12:33 PM|Kyle Lanser|LINK

    The Problem:

    My goal is to enable gzip compression of responses from IIS for the content-type "application/json*", but when the wildcard * is added instead of an exact string match compression fails.

    Enabling the FailedRequestLogs and making a request to IIS for which the response is:

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Length: 41
    Content-Type: application/json; charset=utf-8

    The Result is:
    DYNAMIC_COMPRESSION_NOT_SUCCESS, Reason: NO_MATCHING_CONTENT_TYPE

    My configuration & Results:

    When "C:\Windows\System32\inetsrv\config\applicationHost.config" is configured with:

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" noCompressionForHttp10="false" noCompressionForProxies="false">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <dynamicTypes>
          <add mimeType="application/json*" enabled="true" />
          <add mimeType="*/*" enabled="false" />
      </dynamicTypes>
      <staticTypes>  
          <add mimeType="application/json*" enabled="true" />
          <add mimeType="*/*" enabled="false" />
      </staticTypes>
    </httpCompression>

    The "application/json*" wildcard matching fails.

    But when configured with:

    <add mimeType="application/*" enabled="true" /> 

    The wildcard is evaluated and works correctly.

    Additionally, when configured with:

    <add mimeType="application/json" enabled="true" /> 
    <add mimeType="application/json; charset=utf-8" enabled="true" /> 
    

    The exact string matching also works.

    In further testing, I found that the wildcard only seems to work immediately following the '/' in the mimeType. (ex: "abc/*")

    The Question is, why doesn't wildcard matching work when there are characters after the '/' like in "application/json*"?

    IIS7 httpCompression

  • Re: httpCompression dynamicTypes not matching the wildcard *(star) in “application/json*”

    Jan 30, 2016 02:39 AM|lextm|LINK

    The IIS documentation is sparse in this area, and the observed behaviors you describe probably are by design.

    Most of the ideas come from IIS 6, where due to security concerns wildcard is not even recommended,

    https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0167eb9b-0a38-470c-a33c-1905115e4d2b.mspx?mfr=true

    IIS7 httpCompression

    Lex Li
    Want to have a chat on the issues you meet? Book an appointment at https://buy.stripe.com/cN24ia0yi7sAdIA7sv
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.