Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion Source/UrlRequest_Apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ void Open(UrlMethod method, const std::string& url)
NSString* path = [[NSBundle mainBundle] pathForResource:[m_url.path substringFromIndex:1] ofType:nil];
if (path == nil)
{
throw std::runtime_error{"No file exists at local path"};
// No bundled resource at this path. Don't throw -- let SendAsync's existing
// `if (m_url == nil)` branch complete the task and retain the default status
// code of 0 to indicate a client side error. This matches Win32 / UWP / Unix
// semantics for missing local files.
m_url = nil;
return;
}
Comment thread
bkaradzic-microsoft marked this conversation as resolved.
Resolved
m_url = [NSURL fileURLWithPath:path];
}
Expand Down
30 changes: 21 additions & 9 deletions Source/UrlRequest_Unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,30 @@ namespace UrlLib

m_thread.emplace([this, taskCompletionSource]() mutable
{
curl_check(curl_easy_perform(m_curl));

long codep{};
curl_check(curl_easy_getinfo(m_curl, CURLINFO_RESPONSE_CODE, &codep));
if (codep == 0 && m_file)
try
{
// File scheme always returns 0
m_statusCode = UrlStatusCode::Ok;
curl_check(curl_easy_perform(m_curl));

long codep{};
curl_check(curl_easy_getinfo(m_curl, CURLINFO_RESPONSE_CODE, &codep));
if (codep == 0 && m_file)
{
// File scheme always returns 0
m_statusCode = UrlStatusCode::Ok;
}
else
{
m_statusCode = static_cast<UrlStatusCode>(codep);
}
}
else
catch (const std::exception&)
{
m_statusCode = static_cast<UrlStatusCode>(codep);
// Retain the default status code of 0 to indicate a client side error,
// matching the convention of UrlRequest_UWP.cpp's catch(winrt::hresult_error)
// and UrlRequest_Apple.mm's `m_url == nil` branch. Without this catch any
// libcurl failure (e.g. CURLE_FILE_COULDNT_READ_FILE (37) for a missing local
// `file://` or rewritten `app:///` target) would escape this std::thread and
// call std::terminate.
Comment thread
bkaradzic-microsoft marked this conversation as resolved.
Resolved
}

taskCompletionSource.complete();
Expand Down