2015-09-11 21:26:33 +03:00
|
|
|
#ifndef mozilla_dom_FetchUtil_h
|
|
|
|
#define mozilla_dom_FetchUtil_h
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsError.h"
|
2015-09-17 15:10:42 +03:00
|
|
|
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/File.h"
|
2016-01-07 22:30:36 +03:00
|
|
|
#include "mozilla/dom/FormData.h"
|
2015-09-11 21:26:33 +03:00
|
|
|
|
2016-11-14 10:15:32 +03:00
|
|
|
class nsIPrincipal;
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIHttpChannel;
|
|
|
|
|
2015-09-11 21:26:33 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-11-14 10:15:32 +03:00
|
|
|
class InternalRequest;
|
|
|
|
|
2015-09-11 21:26:33 +03:00
|
|
|
class FetchUtil final
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
FetchUtil() = delete;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Sets outMethod to a valid HTTP request method string based on an input method.
|
|
|
|
* Implements checks and normalization as specified by the Fetch specification.
|
|
|
|
* Returns NS_ERROR_DOM_SECURITY_ERR if the method is invalid.
|
|
|
|
* Otherwise returns NS_OK and the normalized method via outMethod.
|
|
|
|
*/
|
|
|
|
static nsresult
|
|
|
|
GetValidRequestMethod(const nsACString& aMethod, nsCString& outMethod);
|
2015-09-17 15:10:42 +03:00
|
|
|
|
2015-10-25 00:42:35 +03:00
|
|
|
/**
|
|
|
|
* Extracts an HTTP header from a substring range.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
ExtractHeader(nsACString::const_iterator& aStart,
|
|
|
|
nsACString::const_iterator& aEnd,
|
|
|
|
nsCString& aHeaderName,
|
|
|
|
nsCString& aHeaderValue,
|
|
|
|
bool* aWasEmptyHeader);
|
2016-11-14 10:15:32 +03:00
|
|
|
|
|
|
|
static nsresult
|
|
|
|
SetRequestReferrer(nsIPrincipal* aPrincipal,
|
|
|
|
nsIDocument* aDoc,
|
|
|
|
nsIHttpChannel* aChannel,
|
|
|
|
InternalRequest* aRequest);
|
|
|
|
|
2015-09-11 21:26:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif
|