]>
Commit | Line | Data |
---|---|---|
1ab04517 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 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. | |
1ab04517 AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 09 File Transfer Protocol (FTP) */ |
10 | ||
1ab04517 AR |
11 | #include "squid.h" |
12 | #include "ftp/Elements.h" | |
43446566 AR |
13 | #include "HttpHdrCc.h" |
14 | #include "HttpReply.h" | |
65e41a45 | 15 | #include "sbuf/SBuf.h" |
1ab04517 | 16 | |
ecb19f1a AR |
17 | // FTP does not have a notion of a "protocol version" but we need something for |
18 | // compatibility with the current HttpMsg wrapping layer. We use version 1.1: | |
19 | // * some ICAP services probably expect /1.0 or /1.1 when parsing HTTP headers; | |
20 | // * FTP commands are sent on a "persistent by default" connection, just like | |
21 | // HTTP/1.1. Using 1.1 leads to fewer exceptions in current code shared by | |
22 | // HTTP and FTP. | |
23 | AnyP::ProtocolVersion | |
24 | Ftp::ProtocolVersion() | |
25 | { | |
26 | return AnyP::ProtocolVersion(AnyP::PROTO_FTP, 1, 1); | |
27 | } | |
28 | ||
43446566 AR |
29 | HttpReply * |
30 | Ftp::HttpReplyWrapper(const int ftpStatus, const char *ftpReason, const Http::StatusCode httpStatus, const int64_t clen) | |
31 | { | |
32 | HttpReply *const reply = new HttpReply; | |
ecb19f1a | 33 | |
2592bc70 | 34 | AnyP::ProtocolVersion httpVersion = Http::ProtocolVersion( |
3cc0f4e7 | 35 | Ftp::ProtocolVersion().major, Ftp::ProtocolVersion().minor); |
ecb19f1a AR |
36 | reply->sline.set(httpVersion, httpStatus); |
37 | ||
43446566 | 38 | HttpHeader &header = reply->header; |
789217a2 | 39 | header.putTime(Http::HdrType::DATE, squid_curtime); |
43446566 AR |
40 | { |
41 | HttpHdrCc cc; | |
42 | cc.Private(String()); | |
43 | header.putCc(&cc); | |
44 | } | |
45 | if (ftpStatus > 0) | |
789217a2 | 46 | header.putInt(Http::HdrType::FTP_STATUS, ftpStatus); |
43446566 | 47 | if (ftpReason) |
789217a2 | 48 | header.putStr(Http::HdrType::FTP_REASON, ftpReason); |
43446566 | 49 | if (clen >= 0) |
789217a2 | 50 | header.putInt64(Http::HdrType::CONTENT_LENGTH, clen); |
43446566 AR |
51 | reply->hdrCacheInit(); |
52 | return reply; | |
53 | } | |
54 | ||
1ab04517 AR |
55 | const SBuf & |
56 | Ftp::cmdAppe() | |
57 | { | |
58 | static const SBuf cmd("APPE"); | |
59 | return cmd; | |
60 | } | |
61 | ||
62 | const SBuf & | |
63 | Ftp::cmdAuth() | |
64 | { | |
65 | static const SBuf cmd("AUTH"); | |
66 | return cmd; | |
67 | } | |
68 | ||
69 | const SBuf & | |
70 | Ftp::cmdCwd() | |
71 | { | |
72 | static const SBuf cmd("CWD"); | |
73 | return cmd; | |
74 | } | |
75 | ||
76 | const SBuf & | |
77 | Ftp::cmdDele() | |
78 | { | |
79 | static const SBuf cmd("DELE"); | |
80 | return cmd; | |
81 | } | |
82 | ||
83 | const SBuf & | |
84 | Ftp::cmdEprt() | |
85 | { | |
86 | static const SBuf cmd("EPRT"); | |
87 | return cmd; | |
88 | } | |
89 | ||
90 | const SBuf & | |
91 | Ftp::cmdEpsv() | |
92 | { | |
93 | static const SBuf cmd("EPSV"); | |
94 | return cmd; | |
95 | } | |
96 | ||
97 | const SBuf & | |
98 | Ftp::cmdList() | |
99 | { | |
100 | static const SBuf cmd("LIST"); | |
101 | return cmd; | |
102 | } | |
103 | ||
104 | const SBuf & | |
105 | Ftp::cmdMkd() | |
106 | { | |
107 | static const SBuf cmd("MKD"); | |
108 | return cmd; | |
109 | } | |
110 | ||
111 | const SBuf & | |
112 | Ftp::cmdMlsd() | |
113 | { | |
114 | static const SBuf cmd("MLSD"); | |
115 | return cmd; | |
116 | } | |
117 | ||
118 | const SBuf & | |
119 | Ftp::cmdMlst() | |
120 | { | |
121 | static const SBuf cmd("MLST"); | |
122 | return cmd; | |
123 | } | |
124 | ||
125 | const SBuf & | |
126 | Ftp::cmdNlst() | |
127 | { | |
128 | static const SBuf cmd("NLST"); | |
129 | return cmd; | |
130 | } | |
131 | ||
132 | const SBuf & | |
133 | Ftp::cmdRetr() | |
134 | { | |
135 | static const SBuf cmd("RETR"); | |
136 | return cmd; | |
137 | } | |
138 | ||
139 | const SBuf & | |
140 | Ftp::cmdRmd() | |
141 | { | |
142 | static const SBuf cmd("RMD"); | |
143 | return cmd; | |
144 | } | |
145 | ||
146 | const SBuf & | |
147 | Ftp::cmdRnfr() | |
148 | { | |
149 | static const SBuf cmd("RNFR"); | |
150 | return cmd; | |
151 | } | |
152 | ||
153 | const SBuf & | |
154 | Ftp::cmdRnto() | |
155 | { | |
156 | static const SBuf cmd("RNTO"); | |
157 | return cmd; | |
158 | } | |
159 | ||
160 | const SBuf & | |
161 | Ftp::cmdSmnt() | |
162 | { | |
163 | static const SBuf cmd("SMNT"); | |
164 | return cmd; | |
165 | } | |
166 | ||
167 | const SBuf & | |
168 | Ftp::cmdStat() | |
169 | { | |
170 | static const SBuf cmd("STAT"); | |
171 | return cmd; | |
172 | } | |
173 | ||
174 | const SBuf & | |
175 | Ftp::cmdStor() | |
176 | { | |
177 | static const SBuf cmd("STOR"); | |
178 | return cmd; | |
179 | } | |
180 | ||
181 | const SBuf & | |
182 | Ftp::cmdStou() | |
183 | { | |
184 | static const SBuf cmd("STOU"); | |
185 | return cmd; | |
186 | } | |
187 | ||
188 | const SBuf & | |
189 | Ftp::cmdUser() | |
190 | { | |
191 | static const SBuf cmd("USER"); | |
192 | return cmd; | |
193 | } | |
f53969cc | 194 |