FetchUtil.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef mozilla_dom_FetchUtil_h
  2. #define mozilla_dom_FetchUtil_h
  3. #include "nsString.h"
  4. #include "nsError.h"
  5. #include "mozilla/ErrorResult.h"
  6. #include "mozilla/dom/File.h"
  7. #include "mozilla/dom/FormData.h"
  8. namespace mozilla {
  9. namespace dom {
  10. class FetchUtil final
  11. {
  12. private:
  13. FetchUtil() = delete;
  14. public:
  15. /**
  16. * Sets outMethod to a valid HTTP request method string based on an input method.
  17. * Implements checks and normalization as specified by the Fetch specification.
  18. * Returns NS_ERROR_DOM_SECURITY_ERR if the method is invalid.
  19. * Otherwise returns NS_OK and the normalized method via outMethod.
  20. */
  21. static nsresult
  22. GetValidRequestMethod(const nsACString& aMethod, nsCString& outMethod);
  23. /**
  24. * Extracts an HTTP header from a substring range.
  25. */
  26. static bool
  27. ExtractHeader(nsACString::const_iterator& aStart,
  28. nsACString::const_iterator& aEnd,
  29. nsCString& aHeaderName,
  30. nsCString& aHeaderValue,
  31. bool* aWasEmptyHeader);
  32. };
  33. } // namespace dom
  34. } // namespace mozilla
  35. #endif