]>
Commit | Line | Data |
---|---|---|
1ca54a54 | 1 | /* |
ef57eb7b | 2 | * Copyright (C) 1996-2016 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
1ca54a54 | 7 | */ |
bbc27441 AJ |
8 | |
9 | /* DEBUG: section 23 URL Scheme parsing */ | |
10 | ||
1ca54a54 AJ |
11 | #include "squid.h" |
12 | #include "anyp/UriScheme.h" | |
13 | ||
14 | char const * | |
15 | AnyP::UriScheme::c_str() const | |
16 | { | |
17 | if (theScheme_ == AnyP::PROTO_UNKNOWN) | |
18 | return "(unknown)"; | |
19 | ||
20 | static char out[BUFSIZ]; | |
21 | int p = 0; | |
22 | ||
23 | if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX) { | |
24 | const char *in = AnyP::ProtocolType_str[theScheme_]; | |
25 | for (; p < (BUFSIZ-1) && in[p] != '\0'; ++p) | |
26 | out[p] = xtolower(in[p]); | |
27 | } | |
28 | out[p] = '\0'; | |
29 | return out; | |
30 | } | |
f53969cc | 31 | |
5c51bffb AJ |
32 | unsigned short |
33 | AnyP::UriScheme::defaultPort() const | |
34 | { | |
35 | switch (theScheme_) { | |
36 | ||
37 | case AnyP::PROTO_HTTP: | |
38 | return 80; | |
39 | ||
40 | case AnyP::PROTO_HTTPS: | |
41 | return 443; | |
42 | ||
43 | case AnyP::PROTO_FTP: | |
44 | return 21; | |
45 | ||
46 | case AnyP::PROTO_COAP: | |
47 | case AnyP::PROTO_COAPS: | |
48 | // coaps:// default is TBA as of draft-ietf-core-coap-08. | |
49 | // Assuming IANA policy of allocating same port for base and TLS protocol versions will occur. | |
50 | return 5683; | |
51 | ||
52 | case AnyP::PROTO_GOPHER: | |
53 | return 70; | |
54 | ||
55 | case AnyP::PROTO_WAIS: | |
56 | return 210; | |
57 | ||
58 | case AnyP::PROTO_CACHE_OBJECT: | |
59 | return CACHE_HTTP_PORT; | |
60 | ||
61 | case AnyP::PROTO_WHOIS: | |
62 | return 43; | |
63 | ||
64 | default: | |
65 | return 0; | |
66 | } | |
67 | } | |
68 |