blob: b9dc0fa05f8201cc0ca6b8e21690b7e8934909b5 (
plain)
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
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/url_request/ftp_protocol_handler.h"
#include "base/logging.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_error_job.h"
#include "net/url_request/url_request_ftp_job.h"
#include "googleurl/src/gurl.h"
namespace net {
FtpProtocolHandler::FtpProtocolHandler(
NetworkDelegate* network_delegate,
FtpTransactionFactory* ftp_transaction_factory,
FtpAuthCache* ftp_auth_cache)
: network_delegate_(network_delegate),
ftp_transaction_factory_(ftp_transaction_factory),
ftp_auth_cache_(ftp_auth_cache) {
DCHECK(ftp_transaction_factory_);
DCHECK(ftp_auth_cache_);
}
URLRequestJob* FtpProtocolHandler::MaybeCreateJob(
URLRequest* request) const {
int port = request->url().IntPort();
if (request->url().has_port() &&
!IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) {
return new URLRequestErrorJob(request, ERR_UNSAFE_PORT);
}
return new URLRequestFtpJob(request,
network_delegate_,
ftp_transaction_factory_,
ftp_auth_cache_);
}
} // namespace net
|