Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebBrowserComponent: Fix adding custom HTTP headers on Linux #1341

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
19 changes: 17 additions & 2 deletions modules/juce_gui_extra/native/juce_WebBrowserComponent_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class WebKitSymbols final : public DeletedAtShutdown
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (webkit_web_view_load_uri, juce_webkit_web_view_load_uri,
(WebKitWebView*, const gchar*), void)

JUCE_GENERATE_FUNCTION_WITH_DEFAULT (webkit_web_view_load_request, juce_webkit_web_view_load_request,
(WebKitWebView*, WebKitURIRequest*), void)

JUCE_GENERATE_FUNCTION_WITH_DEFAULT (webkit_policy_decision_use, juce_webkit_policy_decision_use,
(WebKitPolicyDecision*), void)

Expand Down Expand Up @@ -334,7 +337,8 @@ class WebKitSymbols final : public DeletedAtShutdown
makeSymbolBinding (juce_webkit_uri_scheme_response_new, "webkit_uri_scheme_response_new"),
makeSymbolBinding (juce_webkit_uri_scheme_response_set_http_headers, "webkit_uri_scheme_response_set_http_headers"),
makeSymbolBinding (juce_webkit_uri_scheme_response_set_status, "webkit_uri_scheme_response_set_status"),
makeSymbolBinding (juce_webkit_uri_scheme_request_finish_with_response, "webkit_uri_scheme_request_finish_with_response"));
makeSymbolBinding (juce_webkit_uri_scheme_request_finish_with_response, "webkit_uri_scheme_request_finish_with_response"),
makeSymbolBinding (juce_webkit_web_view_load_request, "webkit_web_view_load_request"));
}

bool loadGtkSymbols()
Expand Down Expand Up @@ -804,8 +808,19 @@ class GtkChildProcess final : private CommandReceiver::Responder
{
static Identifier urlIdentifier ("url");
auto url = params.getProperty (urlIdentifier, var()).toString();
static Identifier headersIdentifier ("headers");
auto headers = params.getProperty (headersIdentifier, var(StringArray {}));

auto request = webkit_uri_request_new(url.toRawUTF8());
auto http_headers = webkit_uri_request_get_http_headers(request);

WebKitSymbols::getInstance()->juce_webkit_web_view_load_uri (webview, url.toRawUTF8());
for (int i = 0; i < headers.size(); i++) {
const String header = headers[i].toString();
auto name = header.upToFirstOccurrenceOf (":", false, false).trim();
auto value = header.fromFirstOccurrenceOf (":", false, false).trim();
soup_message_headers_append(http_headers, name.toRawUTF8(), value.toRawUTF8());
}
WebKitSymbols::getInstance()->juce_webkit_web_view_load_request (webview, request);
}

void handleDecisionResponse (const var& params)
Expand Down
Loading