Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Expose user defined proxy #196

Merged
merged 3 commits into from
Sep 17, 2020
Merged

Expose user defined proxy #196

merged 3 commits into from
Sep 17, 2020

Conversation

troky
Copy link
Contributor

@troky troky commented Sep 11, 2020

Example:

 var bootstrapper = new MyCouchClientBootstrapper {
    DbConnectionFn = connectionInfo => {
        connectionInfo.Proxy = new WebProxy("http://proxy:3128") {
            Credentials = new NetworkCredential("proxyUsername", "proxyPassword")
        };
        return new DbConnection(connectionInfo);
    }
};

var myCouchClient = new MyCouchClient("http://couchdb/database", bootstrapper);

@danielwertheim
Copy link
Owner

Thanks for the PR. Is there a using or something missing as the build fails on the build server?

Would you still want this to be in or would it be OK to just inherit DbConnection and then override CreateHttpClient - https://github.com/danielwertheim/mycouch/blob/master/source/projects/MyCouch/Net/Connection.cs#L58

I guess there should be a CreateHttpHandler that can be overridden that CreateHttpClient then would use.

Then you just use your type e.g ProxiedDbConnection in the bootstrapper.

@troky
Copy link
Contributor Author

troky commented Sep 15, 2020

Sorry, missed using System.Net.

Well, one can create and override CreateHttpHandler and create ProxiedDbConnection in user code but why?
I think implementing ProxiedDbConnection or exposing Proxy property should be within library, not user code.

My patch is super simple, but I'll accept your idea if it is implemented in MyCouch .NET.

@danielwertheim danielwertheim merged commit 57cd31d into danielwertheim:master Sep 17, 2020
@troky troky deleted the patch-1 branch September 17, 2020 09:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants