Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ inline void fromRawValue(
result.type = ImageSource::Type::Local;
}

if (items.find("headers") != items.end() &&
items.at("headers").hasType<std::unordered_map<std::string, RawValue>>()) {
auto headers = (std::unordered_map<std::string, RawValue>)items.at("headers");
for (const auto &header : headers) {
if (header.second.hasType<std::string>()) {
result.headers[header.first] = (std::string)header.second;
}
}
// Add a debug log to print the headers
LOG(INFO) << "Parsed headers: " << result.headers.size();
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ inline static NSURLRequest *NSURLRequestFromImageSource(const facebook::react::I
request.cachePolicy = ...;
request.allHTTPHeaderFields = ...;
*/
// Set headers
for (const auto &header : imageSource.headers) {
[request setValue:[NSString stringWithUTF8String:header.second.c_str()]
forHTTPHeaderField:[NSString stringWithUTF8String:header.first.c_str()]];
}

return [request copy];
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ImageSource {
std::string bundle{};
Float scale{3};
Size size{0};
std::unordered_map<std::string, std::string> headers{}; // Add headers field


bool operator==(const ImageSource& rhs) const {
return std::tie(this->type, this->uri) == std::tie(rhs.type, rhs.uri);
Expand Down