diff options
author | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 18:28:50 +0000 |
---|---|---|
committer | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 18:28:50 +0000 |
commit | 779f93c652dc0525ef47716eb6b8e3fd511c7b5c (patch) | |
tree | 6bb4ff7aab423c96928b46dc3eed286d12ba5f07 /chrome/browser/chromeos/gdata/gdata_operations.cc | |
parent | a5ea96fef6e2c20afa18c58ddd3b8aa997b460b9 (diff) | |
download | chromium_src-779f93c652dc0525ef47716eb6b8e3fd511c7b5c.zip chromium_src-779f93c652dc0525ef47716eb6b8e3fd511c7b5c.tar.gz chromium_src-779f93c652dc0525ef47716eb6b8e3fd511c7b5c.tar.bz2 |
Merge 144895 - gdata: Uploading of an empty file.
The patch
1) Drops/bypasses several DCHECKs preventing empty upload.
2) Avoids ill-formed PUT request header "Content-Range: 0--1/0" to GData API.
BUG=134552, 132968
TEST=manually tested: put an empty file on local Download folder, and copy to
Google Drive folder in the file manager by drag and drop.
Review URL: https://chromiumcodereview.appspot.com/10636053
TBR=kinaba@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10692166
git-svn-id: svn://svn.chromium.org/chrome/branches/1180/src@146152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/gdata/gdata_operations.cc')
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_operations.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata_operations.cc b/chrome/browser/chromeos/gdata/gdata_operations.cc index dcfde09..479c460 100644 --- a/chrome/browser/chromeos/gdata/gdata_operations.cc +++ b/chrome/browser/chromeos/gdata/gdata_operations.cc @@ -973,11 +973,7 @@ bool InitiateUploadOperation::GetContentData(std::string* upload_content_type, if (params_.upload_mode == UPLOAD_EXISTING_FILE) { // When uploading an existing file, the body is empty as we don't modify // the metadata. - // - // However, URLFetcher DCHECKs with an empty body with PUT request, hence - // sending "\r\n" instead. - // TODO(satorux): Remove the workaround: crbug.com/134261. - *upload_content = "\r\n"; + *upload_content = ""; // Even though the body is empty, Content-Type should be set to // "text/plain". Otherwise, the server won't accept. *upload_content_type = "text/plain"; @@ -1110,6 +1106,13 @@ URLFetcher::RequestType ResumeUploadOperation::GetRequestType() const { } std::vector<std::string> ResumeUploadOperation::GetExtraRequestHeaders() const { + if (params_.content_length == 0) { + // For uploading an empty document, just PUT an empty content. + DCHECK_EQ(params_.start_range, 0); + DCHECK_EQ(params_.end_range, -1); + return std::vector<std::string>(); + } + // The header looks like // Content-Range: bytes <start_range>-<end_range>/<content_length> // for example: |