Package: org.grails.web.mime

## [Groovy] Class HttpServletResponseExtension

- org.grails.web.mime.HttpServletResponseExtension

-     @groovy.transform.CompileStatic
      class HttpServletResponseExtension
      extends java.lang.Object

  Extends the javax.servlet.http.HttpServletResponse object with new methods for handling MimeType instances

  Authors:
    Graeme Rocher
  Since:
    3.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static MimeTypesApiSupport` | `apiSupport` |
    `private static java.util.regex.Pattern` | `disableForUserAgents` |
    `private static MimeType[]` | `mimeTypes` |
    `private static boolean` | `useAcceptHeader` |
    `private static boolean` | `useAcceptHeaderXhr` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `static MimeTypesApiSupport` | `apiSupport`
    `static java.util.regex.Pattern` | `disableForUserAgents`
    `static boolean` | `useAcceptHeader`
    `static boolean` | `useAcceptHeaderXhr`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `HttpServletResponseExtension ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static void` | `()`
    `` | `static java.lang.String` | `getFormat(javax.servlet.http.HttpServletResponse response)` Obtains the format to use for the response using either the file extension or the ACCEPT header
    `` | `static MimeType` | `getMimeType(javax.servlet.http.HttpServletResponse response)` Obtains the MimeType for the response using either the file extension or the ACCEPT header
    `` | `private static MimeType` | `getMimeTypeForRequest(GrailsWebRequest webRequest)`
    `` | `static MimeType[]` | `getMimeTypes()`
    `` | `static MimeType[]` | `getMimeTypes(javax.servlet.http.HttpServletResponse response)` Gets the configured mime types for the response
    `` | `static MimeType[]` | `getMimeTypesFormatAware(javax.servlet.http.HttpServletResponse response)` Gets the configured mime types for the response
    `` | `private static MimeType[]` | `getMimeTypesInternal(javax.servlet.http.HttpServletRequest request)`
    `` | `static void` | `loadMimeTypeConfig(Config config)`
    `` | `private static void` | `useDefaultConfig()`
    `` | `static java.lang.Object` | `withFormat(javax.servlet.http.HttpServletResponse response, groovy.lang.Closure callable)` Allows for the response.withFormat { } syntax

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private static MimeTypesApiSupport apiSupport

    - #### private static java.util.regex.Pattern disableForUserAgents

    - #### private static MimeType[] mimeTypes

    - #### private static boolean useAcceptHeader

    - #### private static boolean useAcceptHeaderXhr

  - ### Property Detail

    - #### static MimeTypesApiSupport apiSupport

    - #### static java.util.regex.Pattern disableForUserAgents

    - #### static boolean useAcceptHeader

    - #### static boolean useAcceptHeaderXhr

  - ### Constructor Detail

    - #### HttpServletResponseExtension()

  - ### Method Detail

    - #### static void ()

    - #### @groovy.transform.CompileStatic static java.lang.String getFormat(javax.servlet.http.HttpServletResponse response)

      Obtains the format to use for the response using either the file extension or the ACCEPT header

      Parameters:
        `response` - The response
      Returns:
        The request format

    - #### @groovy.transform.CompileStatic static MimeType getMimeType(javax.servlet.http.HttpServletResponse response)

      Obtains the MimeType for the response using either the file extension or the ACCEPT header

      Parameters:
        `response` - The response
      Returns:
        The MimeType

    - #### private static MimeType getMimeTypeForRequest(GrailsWebRequest webRequest)

    - #### @groovy.transform.CompileStatic static MimeType[] getMimeTypes()

    - #### static MimeType[] getMimeTypes(javax.servlet.http.HttpServletResponse response)

      Gets the configured mime types for the response

      Parameters:
        `response` - The response
      Returns:
        The configured mime types

    - #### static MimeType[] getMimeTypesFormatAware(javax.servlet.http.HttpServletResponse response)

      Gets the configured mime types for the response

      Parameters:
        `response` - The response
      Returns:
        The configured mime types

    - #### @groovy.transform.CompileDynamic private static MimeType[] getMimeTypesInternal(javax.servlet.http.HttpServletRequest request)

    - #### static void loadMimeTypeConfig(Config config)

    - #### private static void useDefaultConfig()

    - #### static java.lang.Object withFormat(javax.servlet.http.HttpServletResponse response, groovy.lang.Closure callable)

      Allows for the response.withFormat { } syntax

      Parameters:
        `response` - The response
        `callable` - A closure
      Returns:
        The result of the closure call