Package org.eclipse.rdf4j.common.webapp.util

## Class HttpServerUtil

- java.lang.Object
- - org.eclipse.rdf4j.common.webapp.util.HttpServerUtil

-     public class HttpServerUtil
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `HttpServerUtil()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static List<HeaderElement>` | `getHeaderElements​(javax.servlet.http.HttpServletRequest request, String headerName)` | Gets the elements of the request header with the specified name.
    `static String` | `getMIMEType​(String contentType)` | Extracts the MIME type from the specified content type string.
    `static String` | `getPostDataParameter​(Map<String,​Object> formData, String name)` | Gets the trimmed value of a request parameter as a String.
    `static boolean` | `isEmpty​(String string)` |
    `static boolean` | `isFalse​(String string)` |
    `static boolean` | `isTrue​(String string)` |
    `static HeaderElement` | `matchAcceptHeader​(String mimeTypeSpec, List<HeaderElement> acceptElements)` | Tries to match the specified MIME type spec against the list of Accept header elements, returning the applicable header element if available.
    `static String` | `selectPreferredMIMEType​(Iterator<String> mimeTypes, javax.servlet.http.HttpServletRequest request)` | Selects from a set of MIME types, the MIME type that has the highest quality score when matched with the Accept headers in the supplied request.
    `static List<String>` | `splitHeaderString​(String s, char splitChar)` | Splits the supplied string into sub parts using the specified splitChar as a separator, ignoring occurrences of this character inside quoted strings.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpServerUtil

          public HttpServerUtil()

  - ### Method Detail

    - #### getMIMEType

          public static String getMIMEType​(String contentType)

      Extracts the MIME type from the specified content type string. This method parses the content type string and returns just the MIME type, ignoring any parameters that are included.
      Parameters:
        `contentType` - A content type string, e.g. application/xml; charset=utf-8 .
      Returns:
        The MIME type part of the specified content type string, or null if the specified content type string was null.

    - #### selectPreferredMIMEType

          public static String selectPreferredMIMEType​(Iterator<String> mimeTypes,
                                                       javax.servlet.http.HttpServletRequest request)

      Selects from a set of MIME types, the MIME type that has the highest quality score when matched with the Accept headers in the supplied request.
      Parameters:
        `mimeTypes` - The set of available MIME types.
        `request` - The request to match the MIME types against.
      Returns:
        The MIME type that best matches the types that the client finds acceptable, or null in case no acceptable MIME type could be found.

    - #### getHeaderElements

          public static List<HeaderElement> getHeaderElements​(javax.servlet.http.HttpServletRequest request,
                                                              String headerName)

      Gets the elements of the request header with the specified name.
      Parameters:
        `request` - The request to get the header from.
        `headerName` - The name of the header to get the elements of.
      Returns:
        A List of `HeaderElement` objects.

    - #### splitHeaderString

          public static List<String> splitHeaderString​(String s,
                                                       char splitChar)

      Splits the supplied string into sub parts using the specified splitChar as a separator, ignoring occurrences of this character inside quoted strings.
      Parameters:
        `s` - The header string to split into sub parts.
        `splitChar` - The character to use as separator.
      Returns:
        A List of Strings.

    - #### matchAcceptHeader

          public static HeaderElement matchAcceptHeader​(String mimeTypeSpec,
                                                        List<HeaderElement> acceptElements)

      Tries to match the specified MIME type spec against the list of Accept header elements, returning the applicable header element if available.
      Parameters:
        `mimeTypeSpec` - The MIME type to determine the quality for, e.g. "text/plain" or "application/xml; charset=utf-8".
        `acceptElements` - A List of `HeaderElement` objects.
      Returns:
        The Accept header element that matches the MIME type spec most closely, or null if no such header element could be found.

    - #### getPostDataParameter

          public static String getPostDataParameter​(Map<String,​Object> formData,
                                                    String name)

      Gets the trimmed value of a request parameter as a String.
      Returns:
        The trimmed value, or null if the parameter does not exist.

    - #### isEmpty

          public static boolean isEmpty​(String string)

      Returns:
        true if the string is either null or equal to ""

    - #### isTrue

          public static boolean isTrue​(String string)

      Returns:
        true if the string is !isEmpty and equal to "true"

    - #### isFalse

          public static boolean isFalse​(String string)

      Returns:
        true if the string is !isEmpty and equal to "false"