-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement - Simplify Setting of RequestContext Proxy (#3250)
Core - Simplify Setting of Proxy for new RequestContext - Throw exception if requestContext.CanSetPreference returns false. Proxy likely set via command line args. - Add IRequestContext.SetPreferenceAsync - Test - Add SelfHosted Proxy Use Titanium.Web.Proxy to self host a proxy for testing proxy settings Only run Proxy Tests when run locally - Add RequestContext Builder Fluent API
- Loading branch information
Showing
24 changed files
with
875 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// Copyright © 2020 The CefSharp Authors. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
#include "Stdafx.h" | ||
#include "RequestContextBuilder.h" | ||
#include "RequestContext.h" | ||
|
||
namespace CefSharp | ||
{ | ||
IRequestContext^ RequestContextBuilder::Create() | ||
{ | ||
if (_otherContext != nullptr) | ||
{ | ||
return gcnew RequestContext(_otherContext, _handler); | ||
} | ||
|
||
if(_settings != nullptr) | ||
{ | ||
return gcnew RequestContext(_settings, _handler); | ||
} | ||
|
||
return gcnew RequestContext(_handler); | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::OnInitialize(Action<IRequestContext^>^ action) | ||
{ | ||
if (_handler == nullptr) | ||
{ | ||
_handler = gcnew RequestContextHandler(); | ||
} | ||
|
||
_handler->OnInitialize(action); | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::WithPreference(String^ name, Object^ value) | ||
{ | ||
if (_handler == nullptr) | ||
{ | ||
_handler = gcnew RequestContextHandler(); | ||
} | ||
|
||
_handler->SetPreferenceOnContextInitialized(name, value); | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::WithProxyServer(String^ host) | ||
{ | ||
if (_handler == nullptr) | ||
{ | ||
_handler = gcnew RequestContextHandler(); | ||
} | ||
|
||
_handler->SetProxyOnContextInitialized(host, Nullable<int>()); | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::WithProxyServer(String^ host, Nullable<int> port) | ||
{ | ||
if (_handler == nullptr) | ||
{ | ||
_handler = gcnew RequestContextHandler(); | ||
} | ||
|
||
_handler->SetProxyOnContextInitialized(host, port); | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::WithProxyServer(String^ scheme, String^ host, Nullable<int> port) | ||
{ | ||
if (_handler == nullptr) | ||
{ | ||
_handler = gcnew RequestContextHandler(); | ||
} | ||
|
||
_handler->SetProxyOnContextInitialized(scheme, host, port); | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::PersistUserPreferences() | ||
{ | ||
ThrowExceptionIfContextAlreadySet(); | ||
|
||
if (_settings == nullptr) | ||
{ | ||
_settings = gcnew RequestContextSettings(); | ||
} | ||
|
||
_settings->PersistUserPreferences = true; | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::WithCachePath(String^ cachePath) | ||
{ | ||
ThrowExceptionIfContextAlreadySet(); | ||
|
||
if (_settings == nullptr) | ||
{ | ||
_settings = gcnew RequestContextSettings(); | ||
} | ||
|
||
_settings->CachePath = cachePath; | ||
|
||
return this; | ||
} | ||
|
||
RequestContextBuilder^ RequestContextBuilder::WithSharedSettings(IRequestContext^ other) | ||
{ | ||
if (other == nullptr) | ||
{ | ||
throw gcnew ArgumentNullException("other"); | ||
} | ||
|
||
ThrowExceptionIfCustomSettingSpecified(); | ||
|
||
_otherContext = other; | ||
|
||
return this; | ||
} | ||
} |
Oops, something went wrong.