1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_FetchUtil_h
8 #define mozilla_dom_FetchUtil_h
13 #include "mozilla/ErrorResult.h"
14 #include "mozilla/dom/File.h"
15 #include "mozilla/dom/FormData.h"
24 class InternalRequest
;
34 * Sets outMethod to a valid HTTP request method string based on an input method.
35 * Implements checks and normalization as specified by the Fetch specification.
36 * Returns NS_ERROR_DOM_SECURITY_ERR if the method is invalid.
37 * Otherwise returns NS_OK and the normalized method via outMethod.
40 GetValidRequestMethod(const nsACString
& aMethod
, nsCString
& outMethod
);
43 * Extracts an HTTP header from a substring range.
46 ExtractHeader(nsACString::const_iterator
& aStart
,
47 nsACString::const_iterator
& aEnd
,
48 nsCString
& aHeaderName
,
49 nsCString
& aHeaderValue
,
50 bool* aWasEmptyHeader
);
53 SetRequestReferrer(nsIPrincipal
* aPrincipal
,
55 nsIHttpChannel
* aChannel
,
56 InternalRequest
* aRequest
);
59 * Check that the given object is a Response and, if so, stream to the given
60 * JS consumer. On any failure, this function will report an error on the
61 * given JSContext before returning false. If executing in a worker, the
62 * WorkerPrivate must be given.
65 StreamResponseToJS(JSContext
* aCx
,
66 JS::HandleObject aObj
,
67 JS::MimeType aMimeType
,
68 JS::StreamConsumer
* aConsumer
,
69 WorkerPrivate
* aMaybeWorker
);
73 } // namespace mozilla