I'm trying to get and set cookies using the Tor API. The problem is that the SocksPortHandler doesn't have CookieContainer nor InnerHandler.

I tried using Knapcode.SocketToMe.Http.CookieHandler and set its InnerHandler to SocksPortHandler, but with no success. here is the code -

  using (CookieHandler cookieHandler = new CookieHandler())
                SocksPortHandler socksPortHandler = new SocksPortHandler("", socksPort: 9050);
                cookieHandler.InnerHandler = socksPortHandler;
                using (HttpClient httpClient = new HttpClient(cookieHandler))
                   .....setting httpClient properties.....
                    HttpResponseMessage message = httpClient.GetAsync(uri).Result;
                    response = message.Content.ReadAsStringAsync().Result;
                    cookieHeader = cookieHandler.CookieContainer.GetCookieHeader(uri);

how can I do it? Thanks


just found the answer https://github.com/nopara73/DotNetTor/issues/18 hope it will help others

  • Could you describe with a few more words what helped you? Thanks. – Jens Kubieziel Apr 28 '20 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.