mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix mimeType parsing for CDP responses (#53027)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fa66e314b2
commit
e39fd8f79c
@@ -154,7 +154,15 @@ std::string mimeTypeFromHeaders(const Headers& headers) {
|
||||
std::transform(
|
||||
lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
|
||||
if (lowerName == "content-type") {
|
||||
mimeType = value;
|
||||
// Parse MIME type (discarding any parameters after ";") from the
|
||||
// Content-Type header
|
||||
// https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1
|
||||
size_t pos = value.find(';');
|
||||
if (pos != std::string::npos) {
|
||||
mimeType = value.substr(0, pos);
|
||||
} else {
|
||||
mimeType = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user