OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 const String& boundary, | 132 const String& boundary, |
133 const String& contentID, | 133 const String& contentID, |
134 EncodingPolicy encodingPolicy, | 134 EncodingPolicy encodingPolicy, |
135 const SerializedResource& resource, | 135 const SerializedResource& resource, |
136 SharedBuffer& outputBuffer) | 136 SharedBuffer& outputBuffer) |
137 { | 137 { |
138 ASSERT(!boundary.isEmpty()); | 138 ASSERT(!boundary.isEmpty()); |
139 ASSERT(contentID.isEmpty() || contentID[0] == '<'); | 139 ASSERT(contentID.isEmpty() || contentID[0] == '<'); |
140 | 140 |
141 StringBuilder stringBuilder; | 141 StringBuilder stringBuilder; |
142 stringBuilder.append("--" + boundary + "\r\n"); | 142 stringBuilder.append("--"); |
| 143 stringBuilder.append(boundary); |
| 144 stringBuilder.append("\r\n"); |
143 | 145 |
144 stringBuilder.appendLiteral("Content-Type: "); | 146 stringBuilder.appendLiteral("Content-Type: "); |
145 stringBuilder.append(resource.mimeType); | 147 stringBuilder.append(resource.mimeType); |
146 stringBuilder.appendLiteral("\r\n"); | 148 stringBuilder.appendLiteral("\r\n"); |
147 | 149 |
148 if (!contentID.isEmpty()) { | 150 if (!contentID.isEmpty()) { |
149 stringBuilder.appendLiteral("Content-ID: "); | 151 stringBuilder.appendLiteral("Content-ID: "); |
150 stringBuilder.append(contentID); | 152 stringBuilder.append(contentID); |
151 stringBuilder.appendLiteral("\r\n"); | 153 stringBuilder.appendLiteral("\r\n"); |
152 } | 154 } |
153 | 155 |
154 const char* contentEncoding = 0; | 156 const char* contentEncoding = 0; |
155 if (encodingPolicy == UseBinaryEncoding) | 157 if (encodingPolicy == UseBinaryEncoding) |
156 contentEncoding = binary; | 158 contentEncoding = binary; |
157 else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(resource.mimeType)
|| MIMETypeRegistry::isSupportedNonImageMIMEType(resource.mimeType)) | 159 else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(resource.mimeType)
|| MIMETypeRegistry::isSupportedNonImageMIMEType(resource.mimeType)) |
158 contentEncoding = quotedPrintable; | 160 contentEncoding = quotedPrintable; |
159 else | 161 else |
160 contentEncoding = base64; | 162 contentEncoding = base64; |
161 | 163 |
162 stringBuilder.appendLiteral("Content-Transfer-Encoding: "); | 164 stringBuilder.appendLiteral("Content-Transfer-Encoding: "); |
163 stringBuilder.append(contentEncoding); | 165 stringBuilder.append(contentEncoding); |
164 stringBuilder.appendLiteral("\r\n"); | 166 stringBuilder.appendLiteral("\r\n"); |
165 | 167 |
166 if (!resource.url.protocolIsAbout()) { | 168 if (!resource.url.protocolIsAbout()) { |
167 stringBuilder.appendLiteral("Content-Location: "); | 169 stringBuilder.appendLiteral("Content-Location: "); |
168 stringBuilder.append(resource.url); | 170 stringBuilder.append(resource.url.getString()); |
169 stringBuilder.appendLiteral("\r\n"); | 171 stringBuilder.appendLiteral("\r\n"); |
170 } | 172 } |
171 | 173 |
172 stringBuilder.appendLiteral("\r\n"); | 174 stringBuilder.appendLiteral("\r\n"); |
173 | 175 |
174 CString asciiString = stringBuilder.toString().utf8(); | 176 CString asciiString = stringBuilder.toString().utf8(); |
175 outputBuffer.append(asciiString.data(), asciiString.length()); | 177 outputBuffer.append(asciiString.data(), asciiString.length()); |
176 | 178 |
177 if (!strcmp(contentEncoding, binary)) { | 179 if (!strcmp(contentEncoding, binary)) { |
178 const char* data; | 180 const char* data; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 return m_subresources.get(url.getString()); | 237 return m_subresources.get(url.getString()); |
236 } | 238 } |
237 | 239 |
238 DEFINE_TRACE(MHTMLArchive) | 240 DEFINE_TRACE(MHTMLArchive) |
239 { | 241 { |
240 visitor->trace(m_mainResource); | 242 visitor->trace(m_mainResource); |
241 visitor->trace(m_subresources); | 243 visitor->trace(m_subresources); |
242 } | 244 } |
243 | 245 |
244 } // namespace blink | 246 } // namespace blink |
OLD | NEW |