Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: net/ftp/ftp_network_transaction.cc

Issue 5227004: FTP: a successful response to SIZE does not mean the resource is a file. (Closed)
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 break; 971 break;
972 case ERROR_CLASS_OK: 972 case ERROR_CLASS_OK:
973 if (response.lines.size() != 1) 973 if (response.lines.size() != 1)
974 return Stop(ERR_INVALID_RESPONSE); 974 return Stop(ERR_INVALID_RESPONSE);
975 int64 size; 975 int64 size;
976 if (!base::StringToInt64(response.lines[0], &size)) 976 if (!base::StringToInt64(response.lines[0], &size))
977 return Stop(ERR_INVALID_RESPONSE); 977 return Stop(ERR_INVALID_RESPONSE);
978 if (size < 0) 978 if (size < 0)
979 return Stop(ERR_INVALID_RESPONSE); 979 return Stop(ERR_INVALID_RESPONSE);
980 980
981 // Some FTP servers respond with success to the SIZE command 981 // A successful response to SIZE does not mean the resource is a file.
982 // for directories, and return 0 size. Make sure we don't set 982 // Some FTP servers (for example, the qnx one) send a SIZE even for
983 // the resource type to file if that's the case. 983 // directories.
984 if (size > 0) { 984 response_.expected_content_size = size;
985 response_.expected_content_size = size;
986 resource_type_ = RESOURCE_TYPE_FILE;
987 }
988 break; 985 break;
989 case ERROR_CLASS_INFO_NEEDED: 986 case ERROR_CLASS_INFO_NEEDED:
990 break; 987 break;
991 case ERROR_CLASS_TRANSIENT_ERROR: 988 case ERROR_CLASS_TRANSIENT_ERROR:
992 break; 989 break;
993 case ERROR_CLASS_PERMANENT_ERROR: 990 case ERROR_CLASS_PERMANENT_ERROR:
994 // It's possible that SIZE failed because the path is a directory. 991 // It's possible that SIZE failed because the path is a directory.
995 if (resource_type_ == RESOURCE_TYPE_UNKNOWN && 992 if (resource_type_ == RESOURCE_TYPE_UNKNOWN &&
996 response.status_code != 550) { 993 response.status_code != 550) {
997 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code)); 994 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code));
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 if (!had_error_type[type]) { 1336 if (!had_error_type[type]) {
1340 had_error_type[type] = true; 1337 had_error_type[type] = true;
1341 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1338 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1342 type, NUM_OF_NET_ERROR_TYPES); 1339 type, NUM_OF_NET_ERROR_TYPES);
1343 } 1340 }
1344 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1341 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1345 type, NUM_OF_NET_ERROR_TYPES); 1342 type, NUM_OF_NET_ERROR_TYPES);
1346 } 1343 }
1347 1344
1348 } // namespace net 1345 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698