Class HttpParsingUtils

java.lang.Object
com.atlassian.oai.validator.util.HttpParsingUtils

public class HttpParsingUtils extends Object
  • Method Details

    • isMultipartContentTypeAcceptedByConsumer

      public static boolean isMultipartContentTypeAcceptedByConsumer(@Nonnull String requestContentType, @Nonnull String consumesContentType)
      Checks if the content type of a multipart/form-data request matches the consumer's content type.
      Parameters:
      requestContentType - - content-type of a request
      consumesContentType - - content-type that the API consumes
    • extractMultipartBoundary

      @Nonnull public static Optional<String> extractMultipartBoundary(@Nonnull String multipartContentType)
      Extracts boundary from multipart/form-data content type
      Parameters:
      multipartContentType - a multipart form data content type, e.g. "multipart/form-data; boundary=blah"
      Returns:
      the boundary value (blah from the example above) or Optional.empty() if absent
    • parseMultipartFormDataBody

      @Nonnull public static com.google.common.collect.Multimap<String,String> parseMultipartFormDataBody(@Nonnull String multipartContentTypeWithBoundary, @Nonnull String httpBody)
      Parses the body of an HTTP request that was submitted as a multipart document (multipart/mixed)
      Parameters:
      multipartContentTypeWithBoundary - - the content type of a request with the boundary value, e.g. "multipart/mixed; boundary=foobar"
      httpBody - - the body of the request, e.g.: --foobar Content-Disposition: form-data; name="something" some text that you wrote in your html form ... --foobar Content-Disposition: form-data; name="anything" filename="myfile.zip" content --foobar ...
      Returns:
      parsed data
    • parseUrlEncodedFormDataBody

      @Nonnull public static com.google.common.collect.Multimap<String,String> parseUrlEncodedFormDataBody(@Nonnull String httpBody)
      Parses the body of an HTTP request that was submitted as a form (application/x-www-form-urlencoded)
      Parameters:
      httpBody - the body of the HTTP request, e.g. "foo=bar&baz=blah";
    • parseUrlEncodedFormDataBodyAsJsonNode

      @Nonnull public static com.fasterxml.jackson.databind.JsonNode parseUrlEncodedFormDataBodyAsJsonNode(@Nonnull String httpBody)
      Parses the body of an HTTP request that was submitted as a form (application/x-www-form-urlencoded) and transform it into a JSON representation that can be validated with the schema validator.

      Makes some guesses about the intended JSON type based on the field value. Note that this may lead to erroneous validation failures if it guesses wrong.

      Parameters:
      httpBody - the body of the HTTP request, e.g. "foo=bar&baz=blah";
      Returns:
      A JSON representation of the formdata
    • parseUrlEncodedFormDataBodyAsJson

      @Deprecated @Nonnull public static String parseUrlEncodedFormDataBodyAsJson(@Nonnull String httpBody)
      Parses the body of an HTTP request that was submitted as a form (application/x-www-form-urlencoded) and transform it into a JSON representation.