OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 218 } |
219 } else { | 219 } else { |
220 // For non-file blob, use the identifier part of the URL as
the name. | 220 // For non-file blob, use the identifier part of the URL as
the name. |
221 name = "Blob" + BlobURL::getIdentifier(value.blob()->url()); | 221 name = "Blob" + BlobURL::getIdentifier(value.blob()->url()); |
222 name = name.replace("-", ""); // For safety, remove '-' from
the filename since some servers may not like it. | 222 name = name.replace("-", ""); // For safety, remove '-' from
the filename since some servers may not like it. |
223 } | 223 } |
224 | 224 |
225 // We have to include the filename=".." part in the header, even
if the filename is empty | 225 // We have to include the filename=".." part in the header, even
if the filename is empty |
226 FormDataBuilder::addFilenameToMultiPartHeader(header, encoding,
name); | 226 FormDataBuilder::addFilenameToMultiPartHeader(header, encoding,
name); |
227 | 227 |
228 // Add the content type if it is available. | 228 // Add the content type if available, or "application/octet-stre
am" otherwise (RFC 1867). |
229 if (!value.blob()->type().isEmpty()) | 229 String contentType; |
230 FormDataBuilder::addContentTypeToMultiPartHeader(header, val
ue.blob()->type().latin1()); | 230 if (value.blob()->type().isEmpty()) |
| 231 contentType = "application/octet-stream"; |
| 232 else |
| 233 contentType = value.blob()->type(); |
| 234 FormDataBuilder::addContentTypeToMultiPartHeader(header, content
Type.latin1()); |
231 } | 235 } |
232 | 236 |
233 FormDataBuilder::finishMultiPartHeader(header); | 237 FormDataBuilder::finishMultiPartHeader(header); |
234 | 238 |
235 // Append body | 239 // Append body |
236 appendData(header.data(), header.size()); | 240 appendData(header.data(), header.size()); |
237 if (value.blob()) { | 241 if (value.blob()) { |
238 if (value.blob()->isFile()) { | 242 if (value.blob()->isFile()) { |
239 // Do not add the file if the path is empty. | 243 // Do not add the file if the path is empty. |
240 if (!static_cast<File*>(value.blob())->path().isEmpty()) | 244 if (!static_cast<File*>(value.blob())->path().isEmpty()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 String directory = directoryName(e.m_generatedFilename); | 321 String directory = directoryName(e.m_generatedFilename); |
318 deleteFile(e.m_generatedFilename); | 322 deleteFile(e.m_generatedFilename); |
319 deleteEmptyDirectory(directory); | 323 deleteEmptyDirectory(directory); |
320 e.m_generatedFilename = String(); | 324 e.m_generatedFilename = String(); |
321 } | 325 } |
322 } | 326 } |
323 m_hasGeneratedFiles = false; | 327 m_hasGeneratedFiles = false; |
324 } | 328 } |
325 | 329 |
326 } // namespace WebCore | 330 } // namespace WebCore |
OLD | NEW |