Repository navigation
Expand file tree
/
Copy pathInternal.h
More file actions
52 lines (37 loc) · 1.73 KB
/
Copy pathInternal.h
File metadata and controls
52 lines (37 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef NATIVESCRIPT_COMMON_SRC_HTTP_INTERNAL_H_
#define NATIVESCRIPT_COMMON_SRC_HTTP_INTERNAL_H_
#include <chrono>
#include <string>
#include <vector>
#include "ns/http/ModuleFetch.h"
namespace nativescript::common::http {
// "text/javascript; charset=utf-8" → "text/javascript": parameters stripped,
// trimmed, lowercased.
std::string MimeEssence(const std::string& contentType);
// The HTML spec's JavaScript MIME type essence list.
bool IsJavaScriptMimeEssence(const std::string& essence);
// application/json, text/json, or any `+json` subtype.
bool IsJsonMimeEssence(const std::string& essence);
// Judges one response. `arrived` means a status line arrived and, for a 2xx,
// the whole body; everything else (status, MIME, emptiness) is decided here.
// `body` is moved into `result` on success.
void ClassifyModuleResponse(const std::string& url, bool arrived, int status,
const std::string& contentType, std::string& body,
ModuleFetchResult& result);
// Whether any Clear-Site-Data value, each a comma-separated list of quoted
// strings, holds "cache" or "*".
bool ClearSiteDataClearsCache(const std::vector<std::string>& values);
namespace testing {
struct Timing {
std::chrono::milliseconds debugTimeout{30000};
std::chrono::milliseconds releaseTimeout{5000};
std::chrono::milliseconds retryDelay{120};
std::chrono::milliseconds syncWaitMargin{5000};
};
void SetTiming(const Timing& timing);
// Forgets the platform config and the cache switch; the next call reads
// platform::ReadHttpLoaderConfig() again. Only while no fetch is in flight.
void Reset();
} // namespace testing
} // namespace nativescript::common::http
#endif // NATIVESCRIPT_COMMON_SRC_HTTP_INTERNAL_H_