Elements.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
7 */
8
9/* DEBUG: section 09 File Transfer Protocol (FTP) */
10
11#include "squid.h"
12#include "ftp/Elements.h"
13#include "HttpHdrCc.h"
14#include "HttpReply.h"
15#include "sbuf/SBuf.h"
16
17// FTP does not have a notion of a "protocol version" but we need something for
18// compatibility with the current Http::Message 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.
25{
27}
28
30Ftp::HttpReplyWrapper(const int ftpStatus, const char *ftpReason, const Http::StatusCode httpStatus, const int64_t clen)
31{
32 HttpReply *const reply = new HttpReply;
33
36 reply->sline.set(httpVersion, httpStatus);
37
38 HttpHeader &header = reply->header;
40 {
41 HttpHdrCc cc;
42 cc.Private(String());
43 header.putCc(cc);
44 }
45 if (ftpStatus > 0)
46 header.putInt(Http::HdrType::FTP_STATUS, ftpStatus);
47 if (ftpReason)
48 header.putStr(Http::HdrType::FTP_REASON, ftpReason);
49 if (clen >= 0)
51 reply->hdrCacheInit();
52 return reply;
53}
54
55const SBuf &
57{
58 static const SBuf cmd("APPE");
59 return cmd;
60}
61
62const SBuf &
64{
65 static const SBuf cmd("AUTH");
66 return cmd;
67}
68
69const SBuf &
71{
72 static const SBuf cmd("CWD");
73 return cmd;
74}
75
76const SBuf &
78{
79 static const SBuf cmd("DELE");
80 return cmd;
81}
82
83const SBuf &
85{
86 static const SBuf cmd("EPRT");
87 return cmd;
88}
89
90const SBuf &
92{
93 static const SBuf cmd("EPSV");
94 return cmd;
95}
96
97const SBuf &
99{
100 static const SBuf cmd("LIST");
101 return cmd;
102}
103
104const SBuf &
106{
107 static const SBuf cmd("MKD");
108 return cmd;
109}
110
111const SBuf &
113{
114 static const SBuf cmd("MLSD");
115 return cmd;
116}
117
118const SBuf &
120{
121 static const SBuf cmd("MLST");
122 return cmd;
123}
124
125const SBuf &
127{
128 static const SBuf cmd("NLST");
129 return cmd;
130}
131
132const SBuf &
134{
135 static const SBuf cmd("RETR");
136 return cmd;
137}
138
139const SBuf &
141{
142 static const SBuf cmd("RMD");
143 return cmd;
144}
145
146const SBuf &
148{
149 static const SBuf cmd("RNFR");
150 return cmd;
151}
152
153const SBuf &
155{
156 static const SBuf cmd("RNTO");
157 return cmd;
158}
159
160const SBuf &
162{
163 static const SBuf cmd("SMNT");
164 return cmd;
165}
166
167const SBuf &
169{
170 static const SBuf cmd("STAT");
171 return cmd;
172}
173
174const SBuf &
176{
177 static const SBuf cmd("STOR");
178 return cmd;
179}
180
181const SBuf &
183{
184 static const SBuf cmd("STOU");
185 return cmd;
186}
187
188const SBuf &
190{
191 static const SBuf cmd("USER");
192 return cmd;
193}
194
time_t squid_curtime
Definition: stub_libtime.cc:20
void Private(const String &v)
Definition: HttpHdrCc.h:75
void putStr(Http::HdrType id, const char *str)
Definition: HttpHeader.cc:996
void putCc(const HttpHdrCc &cc)
Definition: HttpHeader.cc:1012
void putInt(Http::HdrType id, int number)
Definition: HttpHeader.cc:969
void putInt64(Http::HdrType id, int64_t number)
Definition: HttpHeader.cc:978
void putTime(Http::HdrType id, time_t htime)
Definition: HttpHeader.cc:987
Http::StatusLine sline
Definition: HttpReply.h:56
void hdrCacheInit() override
Definition: HttpReply.cc:321
HttpHeader header
Definition: Message.h:74
void set(const AnyP::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason=nullptr)
Definition: StatusLine.cc:35
Definition: SBuf.h:94
@ PROTO_FTP
Definition: ProtocolType.h:26
const SBuf & cmdAppe()
Definition: Elements.cc:56
AnyP::ProtocolVersion ProtocolVersion()
Protocol version to use in Http::Message structures wrapping FTP messages.
Definition: Elements.cc:24
const SBuf & cmdDele()
Definition: Elements.cc:77
const SBuf & cmdEpsv()
Definition: Elements.cc:91
const SBuf & cmdSmnt()
Definition: Elements.cc:161
const SBuf & cmdStou()
Definition: Elements.cc:182
const SBuf & cmdStor()
Definition: Elements.cc:175
const SBuf & cmdMlsd()
Definition: Elements.cc:112
const SBuf & cmdList()
Definition: Elements.cc:98
const SBuf & cmdRetr()
Definition: Elements.cc:133
const SBuf & cmdNlst()
Definition: Elements.cc:126
const SBuf & cmdMlst()
Definition: Elements.cc:119
const SBuf & cmdStat()
Definition: Elements.cc:168
const SBuf & cmdAuth()
Definition: Elements.cc:63
const SBuf & cmdCwd()
Definition: Elements.cc:70
const SBuf & cmdEprt()
Definition: Elements.cc:84
const SBuf & cmdRnto()
Definition: Elements.cc:154
const SBuf & cmdMkd()
Definition: Elements.cc:105
const SBuf & cmdUser()
Definition: Elements.cc:189
HttpReply * HttpReplyWrapper(const int ftpStatus, const char *ftpReason, const Http::StatusCode httpStatus, const int64_t clen)
Create an internal HttpReply structure to house FTP control response info.
Definition: Elements.cc:30
const SBuf & cmdRnfr()
Definition: Elements.cc:147
const SBuf & cmdRmd()
Definition: Elements.cc:140
StatusCode
Definition: StatusCode.h:20
@ CONTENT_LENGTH
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors