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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#pragma once
#include <the_Foundation/range.h>
#include <the_Foundation/string.h>
iDeclareType(GmError)
iDeclareType(Url)
/* Response status codes. */
enum iGmStatusCode {
/* clientside status codes */
clientSide_GmStatusCode = -100,
invalidRedirect_GmStatusCode,
invalidHeader_GmStatusCode,
unsupportedMimeType_GmStatusCode,
failedToOpenFile_GmStatusCode,
unknownStatusCode_GmStatusCode,
invalidLocalResource_GmStatusCode,
none_GmStatusCode = 0,
/* general status code categories */
categoryInput_GmStatusCode = 1,
categorySuccess_GmStatusCode = 2,
categoryRedirect_GmStatusCode = 3,
categoryTemporaryFailure_GmStatusCode = 4,
categoryPermanentFailure_GmStatusCode = 5,
categoryClientCertificate_GmStatus = 6,
/* detailed status codes */
input_GmStatusCode = 10,
sensitiveInput_GmStatusCode = 11,
success_GmStatusCode = 20,
redirectTemporary_GmStatusCode = 30,
redirectPermanent_GmStatusCode = 31,
temporaryFailure_GmStatusCode = 40,
serverUnavailable_GmStatusCode = 41,
cgiError_GmStatusCode = 42,
proxyError_GmStatusCode = 43,
slowDown_GmStatusCode = 44,
permanentFailure_GmStatusCode = 50,
notFound_GmStatusCode = 51,
gone_GmStatusCode = 52,
proxyRequestRefused_GmStatusCode = 53,
badRequest_GmStatusCode = 59,
clientCertificateRequired_GmStatusCode = 60,
certificateNotAuthorized_GmStatusCode = 61,
certificateNotValid_GmStatusCode = 62,
};
iLocalDef enum iGmStatusCode category_GmStatusCode(enum iGmStatusCode code) {
if (code < 0) return 0;
if (code < 10) return code;
return code / 10;
}
struct Impl_GmError {
iChar icon;
const char *title;
const char *info;
};
iBool isDefined_GmError (enum iGmStatusCode code);
const iGmError * get_GmError (enum iGmStatusCode code);
struct Impl_Url {
iRangecc protocol;
iRangecc host;
iRangecc port;
iRangecc path;
iRangecc query;
};
void init_Url (iUrl *, const iString *text);
iRangecc urlHost_String (const iString *);
const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative);
iString * makeFileUrl_String (const iString *localFilePath);
void urlEncodeSpaces_String (iString *);
|