Add interface method called AddHeaders?

41 views
Skip to first unread message

Andrew Bailey

unread,
Aug 1, 2019, 4:04:02 PM8/1/19
to RestSharp
Would there be any interest in me contributing an interface member called `AddHeaders`?

I have a use case where we compile a Dictionary<string, string> of headers and I have created my own extension method.

I'm considering contributing that but wanted to get consensus before proceeding with a PR.

The signature would be something like this (of course I'd fill in the implementations as well):

/// <summary>
/// Uses AddHeader(name, value) in a convenient way to pass
/// in multiple headers at once.
/// </summary>
/// <param name="headers">Key/Value pairs containing the name: value of the headers</param>
/// <returns></returns>
IRestRequest AddHeaders(Dictionary<string, string> headers);

The implementation essentially just loops over the key/value pairs and adds a header for each pair.

Thoughts?

Andrew Bailey

ENS Brian Hart

unread,
Aug 3, 2019, 3:49:44 PM8/3/19
to rest...@googlegroups.com
I like how it is Fluent, in that it returns a reference to IRestRequest so you can call it in a chain of other method calls.  

One thing I would do is, instead of make it take a Dictionary<string, string>, make it an ICollection<KeyValuePair<string, string>> for max generality.   This is the interface that Dictionary<string, string> implements.
--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/restsharp/b6d4032c-19c5-4eff-9776-4cd5a7ef3e6a%40googlegroups.com.

Alexey Zimarev

unread,
Aug 4, 2019, 3:51:39 PM8/4/19
to RestSharp
Both would work for me, I see no reason not to have such a method. Concerning the parameter, I would prefer to have the dictionary to make it explicit that parameter names should be unique.

Tall Navy Guy

unread,
Aug 4, 2019, 7:56:11 PM8/4/19
to rest...@googlegroups.com
My recommendation would be that the function that is implemented, e.g., AddHeaders, add a validation for the uniqueness of key names (irrespective of case) and throw an exception or something if this is not the case.

There is utility for this function, it makes it a lot cleaner to add headers than do it onesie-twosie.

On Sun, Aug 4, 2019 at 3:51 PM Alexey Zimarev <azim...@gmail.com> wrote:
Both would work for me, I see no reason not to have such a method. Concerning the parameter, I would prefer to have the dictionary to make it explicit that parameter names should be unique.

--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+...@googlegroups.com.
Message has been deleted

Andrew Bailey

unread,
Aug 7, 2019, 2:51:37 PM8/7/19
to RestSharp
So, I've got a local branch and want to start the PR process. I'm getting an authentication error trying to publish my branch.

Total noob here on contributing to public projects.

Anyone able to point me in the right direction?

Side note: I am creating tests and am not yet finished, but ran into a snag getting authenticated. I wanted to move my dev work to a separate machine and couldn't push my branch out.

Thanks!


On Sunday, August 4, 2019 at 6:56:11 PM UTC-5, Tall Navy Guy wrote:
My recommendation would be that the function that is implemented, e.g., AddHeaders, add a validation for the uniqueness of key names (irrespective of case) and throw an exception or something if this is not the case.

There is utility for this function, it makes it a lot cleaner to add headers than do it onesie-twosie.

On Sun, Aug 4, 2019 at 3:51 PM Alexey Zimarev <azim...@gmail.com> wrote:
Both would work for me, I see no reason not to have such a method. Concerning the parameter, I would prefer to have the dictionary to make it explicit that parameter names should be unique.

--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest...@googlegroups.com.

Andrew Bailey

unread,
Aug 20, 2019, 3:54:49 PM8/20/19
to RestSharp
Anyone able to offer assistance? Sorry I'm new to contributing to public projects. Any help is appreciated!

Alexey Zimarev

unread,
Aug 25, 2019, 7:55:55 AM8/25/19
to RestSharp
Reply all
Reply to author
Forward
0 new messages