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

Set Headers now iterates over key #413

Merged
merged 3 commits into from
Jul 8, 2014
Merged

Set Headers now iterates over key #413

merged 3 commits into from
Jul 8, 2014

Conversation

rlmcneary2
Copy link
Contributor

The NameValueCollection iterator returns the string key, not a KeyValuePair.

The NameValueCollection iterator returns the string key, not a
KeyValuePair.
Tabs -> spaces per cefsharp guidelines.
@amaitland amaitland added the cef3 label Jul 2, 2014
@amaitland amaitland added this to the 31.0.0 milestone Jul 2, 2014
@amaitland
Copy link
Member

@rlmcneary2 Thanks for the contribution! Much appreciated 😄

As NameValueCollection supports multiple values per key, should we support mapping all values? e.g.

auto values = headers->GetValues(key);

for each (String^ val in values)
{
    CefString value = StringUtils::ToNative(val);
    hm.insert(std::make_pair(name, value));
}

Thoughts?

@amaitland
Copy link
Member

Out of curiosity, in what scenario do you manually Set headers?

@rlmcneary2
Copy link
Contributor Author

@amaitland I don't use NameValueCollection often so I forgot it allows duplicate keys. What's the process? Should go ahead and make the change and submit a new pull request?

Way too long answer to second comment - Long ago I created a small set of interfaces around the C# WebBrowser control (IE) that is used in a product I work on. Later there was a desire to have the same browser available on XP and Win7, and to use a "modern" browser. So I implemented the same interfaces around CefSharp1 (now we can decide at runtime which browser to start). At that time I needed to set headers and the only way to get it to work consistently was through the OnBeforeResourceLoad method. Two headers are set: "Accept-Language" because we always have the OS in US English but allow the application language to be changed while the application is running, and "User-Agent" because some web sites (Face_COUGH_book) sniff the user agent and return a mobile or desktop layout based on that even if you have requested a specific layout. Now that I'm implementing CefSharp3 (to get an even "moderner" browser) I just want to do as much of a search and replace of CefSharp1 as I can.

For each key get each of the values that matches the key.
@amaitland
Copy link
Member

@rlmcneary2 No need to create a new PR, you can simply commit changes then push, and they should appear here no problem.

Thanks for the long/short answer, always curious about how people are using CefSharp 😄

@amaitland
Copy link
Member

@rlmcneary2 I see you've pushed another change, nice! 😄

I'll check it out tomorrow, first glance looks 👍
Appreciate the contribution!

@amaitland
Copy link
Member

Works as advertised 👍 Thanks!

amaitland added a commit that referenced this pull request Jul 8, 2014
Set Headers now iterates over key
@amaitland amaitland merged commit a29f564 into cefsharp:master Jul 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants