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

How to switch b/w socket and http client worker? #43

Open
QAInsights opened this issue Aug 24, 2020 · 2 comments
Open

How to switch b/w socket and http client worker? #43

QAInsights opened this issue Aug 24, 2020 · 2 comments

Comments

@QAInsights
Copy link

Could you please explain how do we configure or switch between the workers. Read me is confusing.

@simon-flanagan
Copy link

In order to switch to the HttpClientWorkerJob you need to replace:

var worker = new Worker(new SocketWorkerJob(uri));
with
var worker = new Worker(new HttpClientWorkerJob(uri));

In the demo WPF app this is in MainWindow.xaml.cs in the StartButton_Click method. You will find something similar in the console application.

I wanted to inject some cookies into the request - in order to do this you need to modify HttpClientWorkerJob to add the cookie when the HttpClient is instantiated e.g.

           var cookieContainer = new CookieContainer();
            var cookieHandler = new HttpClientHandler { 
                CookieContainer = cookieContainer
            };

            var cookie = new Cookie("cookieName", "cookieValue");
            cookie.Domain = "https://somedomain.com";
            cookieContainer.Add(cookie);

            _httpClient = new HttpClient(cookieHandler);

Hope this helps someone else!

@QAInsights
Copy link
Author

Thanks @simon-flanagan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants