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

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

Issue 197050: Return ERR_FILE_NOT_FOUND from FtpNetworkTransaction when we can. (Closed)
Patch Set: clarify Created 11 years, 3 months 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) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // 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/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/connection_type_histograms.h" 9 #include "net/base/connection_type_histograms.h"
10 #include "net/base/load_log.h" 10 #include "net/base/load_log.h"
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 break; 821 break;
822 case ERROR_CLASS_INFO_NEEDED: 822 case ERROR_CLASS_INFO_NEEDED:
823 next_state_ = STATE_CTRL_WRITE_PASV; 823 next_state_ = STATE_CTRL_WRITE_PASV;
824 break; 824 break;
825 case ERROR_CLASS_TRANSIENT_ERROR: 825 case ERROR_CLASS_TRANSIENT_ERROR:
826 if (response.status_code == 421 || response.status_code == 425 || 826 if (response.status_code == 421 || response.status_code == 425 ||
827 response.status_code == 426) 827 response.status_code == 426)
828 return Stop(ERR_FAILED); 828 return Stop(ERR_FAILED);
829 return ERR_FAILED; // TODO(ibrar): Retry here. 829 return ERR_FAILED; // TODO(ibrar): Retry here.
830 case ERROR_CLASS_PERMANENT_ERROR: 830 case ERROR_CLASS_PERMANENT_ERROR:
831 if (retr_failed_) 831 // Code 550 means "Failed to open file". Other codes are unrelated,
832 // like "Not logged in" etc.
833 if (response.status_code != 550)
832 return Stop(ERR_FAILED); 834 return Stop(ERR_FAILED);
835
836 DCHECK(!retr_failed_); // Should not get here twice.
833 retr_failed_ = true; 837 retr_failed_ = true;
wtc 2009/09/09 18:41:31 My question is: are we going to try the CWD comman
834 next_state_ = STATE_CTRL_WRITE_PASV; 838 next_state_ = STATE_CTRL_WRITE_PASV;
835 break; 839 break;
836 default: 840 default:
837 NOTREACHED(); 841 NOTREACHED();
838 return Stop(ERR_UNEXPECTED); 842 return Stop(ERR_UNEXPECTED);
839 } 843 }
840 return OK; 844 return OK;
841 } 845 }
842 846
843 // MDMT command 847 // MDMT command
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 case ERROR_CLASS_INITIATED: 898 case ERROR_CLASS_INITIATED:
895 return Stop(ERR_INVALID_RESPONSE); 899 return Stop(ERR_INVALID_RESPONSE);
896 case ERROR_CLASS_OK: 900 case ERROR_CLASS_OK:
897 next_state_ = STATE_CTRL_WRITE_LIST; 901 next_state_ = STATE_CTRL_WRITE_LIST;
898 break; 902 break;
899 case ERROR_CLASS_INFO_NEEDED: 903 case ERROR_CLASS_INFO_NEEDED:
900 return Stop(ERR_INVALID_RESPONSE); 904 return Stop(ERR_INVALID_RESPONSE);
901 case ERROR_CLASS_TRANSIENT_ERROR: 905 case ERROR_CLASS_TRANSIENT_ERROR:
902 return Stop(ERR_FAILED); 906 return Stop(ERR_FAILED);
903 case ERROR_CLASS_PERMANENT_ERROR: 907 case ERROR_CLASS_PERMANENT_ERROR:
908 if (retr_failed_ && response.status_code == 550) {
909 // Both RETR and CWD failed with codes 550. That means that the path
910 // we're trying to access is not a file, and not a directory. The most
911 // probable interpretation is that it doesn't exist (with FTP we can't
912 // be sure).
913 return Stop(ERR_FILE_NOT_FOUND);
914 }
904 return Stop(ERR_FAILED); 915 return Stop(ERR_FAILED);
905 default: 916 default:
906 NOTREACHED(); 917 NOTREACHED();
907 return Stop(ERR_UNEXPECTED); 918 return Stop(ERR_UNEXPECTED);
908 } 919 }
909 return OK; 920 return OK;
910 } 921 }
911 922
912 // LIST command 923 // LIST command
913 int FtpNetworkTransaction::DoCtrlWriteLIST() { 924 int FtpNetworkTransaction::DoCtrlWriteLIST() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 read_data_buf_->data()[0] = 0; 1004 read_data_buf_->data()[0] = 0;
994 return data_socket_->Read(read_data_buf_, read_data_buf_len_, 1005 return data_socket_->Read(read_data_buf_, read_data_buf_len_,
995 &io_callback_); 1006 &io_callback_);
996 } 1007 }
997 1008
998 int FtpNetworkTransaction::DoDataReadComplete(int result) { 1009 int FtpNetworkTransaction::DoDataReadComplete(int result) {
999 return result; 1010 return result;
1000 } 1011 }
1001 1012
1002 } // namespace net 1013 } // 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