| 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("--"); | 142 stringBuilder.append("--" + boundary + "\r\n"); |
| 143 stringBuilder.append(boundary); | |
| 144 stringBuilder.append("\r\n"); | |
| 145 | 143 |
| 146 stringBuilder.appendLiteral("Content-Type: "); | 144 stringBuilder.appendLiteral("Content-Type: "); |
| 147 stringBuilder.append(resource.mimeType); | 145 stringBuilder.append(resource.mimeType); |
| 148 stringBuilder.appendLiteral("\r\n"); | 146 stringBuilder.appendLiteral("\r\n"); |
| 149 | 147 |
| 150 if (!contentID.isEmpty()) { | 148 if (!contentID.isEmpty()) { |
| 151 stringBuilder.appendLiteral("Content-ID: "); | 149 stringBuilder.appendLiteral("Content-ID: "); |
| 152 stringBuilder.append(contentID); | 150 stringBuilder.append(contentID); |
| 153 stringBuilder.appendLiteral("\r\n"); | 151 stringBuilder.appendLiteral("\r\n"); |
| 154 } | 152 } |
| 155 | 153 |
| 156 const char* contentEncoding = 0; | 154 const char* contentEncoding = 0; |
| 157 if (encodingPolicy == UseBinaryEncoding) | 155 if (encodingPolicy == UseBinaryEncoding) |
| 158 contentEncoding = binary; | 156 contentEncoding = binary; |
| 159 else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(resource.mimeType)
|| MIMETypeRegistry::isSupportedNonImageMIMEType(resource.mimeType)) | 157 else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(resource.mimeType)
|| MIMETypeRegistry::isSupportedNonImageMIMEType(resource.mimeType)) |
| 160 contentEncoding = quotedPrintable; | 158 contentEncoding = quotedPrintable; |
| 161 else | 159 else |
| 162 contentEncoding = base64; | 160 contentEncoding = base64; |
| 163 | 161 |
| 164 stringBuilder.appendLiteral("Content-Transfer-Encoding: "); | 162 stringBuilder.appendLiteral("Content-Transfer-Encoding: "); |
| 165 stringBuilder.append(contentEncoding); | 163 stringBuilder.append(contentEncoding); |
| 166 stringBuilder.appendLiteral("\r\n"); | 164 stringBuilder.appendLiteral("\r\n"); |
| 167 | 165 |
| 168 if (!resource.url.protocolIsAbout()) { | 166 if (!resource.url.protocolIsAbout()) { |
| 169 stringBuilder.appendLiteral("Content-Location: "); | 167 stringBuilder.appendLiteral("Content-Location: "); |
| 170 stringBuilder.append(resource.url.getString()); | 168 stringBuilder.append(resource.url); |
| 171 stringBuilder.appendLiteral("\r\n"); | 169 stringBuilder.appendLiteral("\r\n"); |
| 172 } | 170 } |
| 173 | 171 |
| 174 stringBuilder.appendLiteral("\r\n"); | 172 stringBuilder.appendLiteral("\r\n"); |
| 175 | 173 |
| 176 CString asciiString = stringBuilder.toString().utf8(); | 174 CString asciiString = stringBuilder.toString().utf8(); |
| 177 outputBuffer.append(asciiString.data(), asciiString.length()); | 175 outputBuffer.append(asciiString.data(), asciiString.length()); |
| 178 | 176 |
| 179 if (!strcmp(contentEncoding, binary)) { | 177 if (!strcmp(contentEncoding, binary)) { |
| 180 const char* data; | 178 const char* data; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return m_subresources.get(url.getString()); | 235 return m_subresources.get(url.getString()); |
| 238 } | 236 } |
| 239 | 237 |
| 240 DEFINE_TRACE(MHTMLArchive) | 238 DEFINE_TRACE(MHTMLArchive) |
| 241 { | 239 { |
| 242 visitor->trace(m_mainResource); | 240 visitor->trace(m_mainResource); |
| 243 visitor->trace(m_subresources); | 241 visitor->trace(m_subresources); |
| 244 } | 242 } |
| 245 | 243 |
| 246 } // namespace blink | 244 } // namespace blink |
| OLD | NEW |