Skip to content

Commit e39fd8f

Browse files
huntiefacebook-github-bot
authored andcommitted
Fix mimeType parsing for CDP responses (#53027)
Summary: Pull Request resolved: #53027 Tweaks MIME type parsing in CDP Network messages, now matching Chrome. This fixes response preview behaviour by the frontend for text response previews that are `base64Encoded` 🙌🏻 (we were observing these for JSON `fetch` calls on iOS). Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D79559495 fbshipit-source-id: 2565af7587fc6fbdd3ef6fcbb10c558341ddfbdc
1 parent fa66e31 commit e39fd8f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • packages/react-native/ReactCommon/jsinspector-modern/network

packages/react-native/ReactCommon/jsinspector-modern/network/HttpUtils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ std::string mimeTypeFromHeaders(const Headers& headers) {
154154
std::transform(
155155
lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
156156
if (lowerName == "content-type") {
157-
mimeType = value;
157+
// Parse MIME type (discarding any parameters after ";") from the
158+
// Content-Type header
159+
// https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1
160+
size_t pos = value.find(';');
161+
if (pos != std::string::npos) {
162+
mimeType = value.substr(0, pos);
163+
} else {
164+
mimeType = value;
165+
}
158166
break;
159167
}
160168
}

0 commit comments

Comments
 (0)