OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 25 matching lines...) Expand all Loading... |
36 { | 36 { |
37 CString encodedString = m_encoding.encode(string, WTF::EntitiesForUnencodabl
es); | 37 CString encodedString = m_encoding.encode(string, WTF::EntitiesForUnencodabl
es); |
38 m_items.append(normalizeLineEndingsToCRLF(encodedString)); | 38 m_items.append(normalizeLineEndingsToCRLF(encodedString)); |
39 } | 39 } |
40 | 40 |
41 void FormDataList::appendString(const CString& string) | 41 void FormDataList::appendString(const CString& string) |
42 { | 42 { |
43 m_items.append(string); | 43 m_items.append(string); |
44 } | 44 } |
45 | 45 |
46 void FormDataList::appendBlob(PassRefPtr<Blob> blob, const String& filename) | 46 void FormDataList::appendBlob(PassRefPtrWillBeRawPtr<Blob> blob, const String& f
ilename) |
47 { | 47 { |
48 m_items.append(Item(blob, filename)); | 48 m_items.append(Item(blob, filename)); |
49 } | 49 } |
50 | 50 |
51 PassRefPtr<FormData> FormDataList::createFormData(const WTF::TextEncoding& encod
ing, FormData::EncodingType encodingType) | 51 PassRefPtr<FormData> FormDataList::createFormData(const WTF::TextEncoding& encod
ing, FormData::EncodingType encodingType) |
52 { | 52 { |
53 RefPtr<FormData> result = FormData::create(); | 53 RefPtr<FormData> result = FormData::create(); |
54 appendKeyValuePairItemsTo(result.get(), encoding, false, encodingType); | 54 appendKeyValuePairItemsTo(result.get(), encoding, false, encodingType); |
55 return result.release(); | 55 return result.release(); |
56 } | 56 } |
57 | 57 |
58 PassRefPtr<FormData> FormDataList::createMultiPartFormData(const WTF::TextEncodi
ng& encoding) | 58 PassRefPtr<FormData> FormDataList::createMultiPartFormData(const WTF::TextEncodi
ng& encoding) |
59 { | 59 { |
60 RefPtr<FormData> result = FormData::create(); | 60 RefPtr<FormData> result = FormData::create(); |
61 appendKeyValuePairItemsTo(result.get(), encoding, true); | 61 appendKeyValuePairItemsTo(result.get(), encoding, true); |
62 return result.release(); | 62 return result.release(); |
63 } | 63 } |
64 | 64 |
65 void FormDataList::appendKeyValuePairItemsTo(FormData* formData, const WTF::Text
Encoding& encoding, bool isMultiPartForm, FormData::EncodingType encodingType) | 65 void FormDataList::appendKeyValuePairItemsTo(FormData* formData, const WTF::Text
Encoding& encoding, bool isMultiPartForm, FormData::EncodingType encodingType) |
66 { | 66 { |
67 if (isMultiPartForm) | 67 if (isMultiPartForm) |
68 formData->setBoundary(FormDataBuilder::generateUniqueBoundaryString()); | 68 formData->setBoundary(FormDataBuilder::generateUniqueBoundaryString()); |
69 | 69 |
70 Vector<char> encodedData; | 70 Vector<char> encodedData; |
71 | 71 |
72 const Vector<FormDataList::Item>& items = this->items(); | 72 const WillBeHeapVector<Item>& items = this->items(); |
73 size_t formDataListSize = items.size(); | 73 size_t formDataListSize = items.size(); |
74 ASSERT(!(formDataListSize % 2)); | 74 ASSERT(!(formDataListSize % 2)); |
75 for (size_t i = 0; i < formDataListSize; i += 2) { | 75 for (size_t i = 0; i < formDataListSize; i += 2) { |
76 const FormDataList::Item& key = items[i]; | 76 const FormDataList::Item& key = items[i]; |
77 const FormDataList::Item& value = items[i + 1]; | 77 const FormDataList::Item& value = items[i + 1]; |
78 if (isMultiPartForm) { | 78 if (isMultiPartForm) { |
79 Vector<char> header; | 79 Vector<char> header; |
80 FormDataBuilder::beginMultiPartHeader(header, formData->boundary().d
ata(), key.data()); | 80 FormDataBuilder::beginMultiPartHeader(header, formData->boundary().d
ata(), key.data()); |
81 | 81 |
82 // If the current type is blob, then we also need to include the fil
ename | 82 // If the current type is blob, then we also need to include the fil
ename |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 FormDataBuilder::addKeyValuePairAsFormData(encodedData, key.data(),
value.data(), encodingType); | 133 FormDataBuilder::addKeyValuePairAsFormData(encodedData, key.data(),
value.data(), encodingType); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 if (isMultiPartForm) | 137 if (isMultiPartForm) |
138 FormDataBuilder::addBoundaryToMultiPartHeader(encodedData, formData->bou
ndary().data(), true); | 138 FormDataBuilder::addBoundaryToMultiPartHeader(encodedData, formData->bou
ndary().data(), true); |
139 | 139 |
140 formData->appendData(encodedData.data(), encodedData.size()); | 140 formData->appendData(encodedData.data(), encodedData.size()); |
141 } | 141 } |
142 | 142 |
| 143 void FormDataList::trace(Visitor* visitor) |
| 144 { |
| 145 visitor->trace(m_items); |
| 146 } |
| 147 |
| 148 void FormDataList::Item::trace(Visitor* visitor) |
| 149 { |
| 150 visitor->trace(m_blob); |
| 151 } |
| 152 |
143 } // namespace | 153 } // namespace |
OLD | NEW |