diff --git a/ClrHttpRequest/ClrHttpRequest.jfm b/ClrHttpRequest/ClrHttpRequest.jfm
deleted file mode 100644
index 63a0db7..0000000
Binary files a/ClrHttpRequest/ClrHttpRequest.jfm and /dev/null differ
diff --git a/ClrHttpRequest/ClrHttpRequest.sqlproj b/ClrHttpRequest/ClrHttpRequest.sqlproj
index f458e79..5e1f031 100644
--- a/ClrHttpRequest/ClrHttpRequest.sqlproj
+++ b/ClrHttpRequest/ClrHttpRequest.sqlproj
@@ -17,7 +17,7 @@
1033, CI
BySchemaAndSchemaType
True
- v4.5
+ v4.7.2
CS
Properties
False
@@ -33,6 +33,7 @@
SIMPLE
3.0.0.0
CHECKSUM
+
bin\Release\
diff --git a/ClrHttpRequest/clr_http_request.cs b/ClrHttpRequest/clr_http_request.cs
index 17ccac9..6c64d17 100644
--- a/ClrHttpRequest/clr_http_request.cs
+++ b/ClrHttpRequest/clr_http_request.cs
@@ -123,20 +123,45 @@ SqlBoolean convertResponseToBas64
request.Credentials = new NetworkCredential(netCredValues[0], netCredValues[1]);
break;
case "PROXY":
- var proxyValues = headerValue.Split(':');
+ var proxyValues = headerValue.Split(',');
if (proxyValues.Length < 2)
{
- throw new FormatException("When specifying the PROXY header, please set the value in a format of URI:PORT");
+ throw new FormatException("When specifying the PROXY header, please set the value in a format of URI,PORT (you can also specify credentials using the format URI,PORT,username:password)");
}
int proxyPort;
if (!int.TryParse(proxyValues[1], out proxyPort))
{
- throw new FormatException("When specifying the PROXY header in the format of URI:PORT, the PORT must be numeric");
+ throw new FormatException("When specifying the PROXY header in the format of URI,PORT the PORT must be numeric");
}
WebProxy myproxy = new WebProxy(proxyValues[0], proxyPort);
myproxy.BypassProxyOnLocal = false;
+
+ if (proxyValues.Length > 2)
+ {
+ var proxyCred = proxyValues[2].Split(':');
+ if (proxyCred.Length < 2)
+ {
+ throw new FormatException("When specifying the PROXY header, please set the value in a format of URI,PORT (you can also specify credentials using the format URI,PORT,username:password)");
+ }
+ else
+ {
+ var proxyCredPassword = proxyCred[1];
+
+ // if the password contains colon characters, re-stich them back into the password
+ for (int i = 2; i < proxyCred.Length - 1; i++)
+ {
+ proxyCredPassword += ":" + proxyCred[i];
+ }
+
+ myproxy.Credentials = new NetworkCredential(proxyCred[0], proxyCredPassword);
+ }
+ }
+
request.Proxy = myproxy;
break;
+ case "TrustServerCertificate":
+ ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
+ break;
default: // other headers
request.Headers.Add(headerName, headerValue);
break;
diff --git a/README.md b/README.md
index f8dfa7b..08dfe17 100644
--- a/README.md
+++ b/README.md
@@ -15,10 +15,11 @@ My version extends the project by adding the following:
* Two new authentication methods:
* Authorization-Basic-Credentials (Basic authorization using Base64 credentials)
* Authorization-Network-Credentials (creates a new `NetworkCredential` object and assigns it to the `Credentials` property of the request)
-* Added support for using a `Proxy` with a new "Proxy" header in the form of `URI:PORT`. For example: ``
+* Added support for using a `Proxy` with a new "Proxy" header in the form of `URI,PORT[,username:password]` (credentials are optional). For example: ``
* Addition of a proper PreDeployment script which takes care of CLR assembly signing without requiring the TRUSTWORTHY database setting.
* Added UTF8 encoding support instead of ASCII.
* Added support for case-insensitive headers.
+* Added support for TrustServerCertificate header. For example: ``
The following code was added in clr_http_request.cs, line 19:
```cs
@@ -39,18 +40,40 @@ The following code was added in line 79 to add support for special headers:
request.Credentials = new NetworkCredential(netCredValues[0], netCredValues[1]);
break;
case "Proxy":
- var proxyValues = headerValue.Split(':');
+ var proxyValues = headerValue.Split(',');
if (proxyValues.Length < 2)
{
- throw new FormatException("When specifying the PROXY header, please set the value in a format of URI:PORT");
+ throw new FormatException("When specifying the PROXY header, please set the value in a format of URI,PORT (you can also specify credentials using the format URI,PORT,username:password)");
}
int proxyPort;
if (!int.TryParse(proxyValues[1], out proxyPort))
{
- throw new FormatException("When specifying the PROXY header in the format of URI:PORT, the PORT must be numeric");
+ throw new FormatException("When specifying the PROXY header in the format of URI,PORT the PORT must be numeric");
}
WebProxy myproxy = new WebProxy(proxyValues[0], proxyPort);
myproxy.BypassProxyOnLocal = false;
+
+ if (proxyValues.Length > 2)
+ {
+ var proxyCred = proxyValues[2].Split(':');
+ if (proxyCred.Length < 2)
+ {
+ throw new FormatException("When specifying the PROXY header, please set the value in a format of URI,PORT (you can also specify credentials using the format URI,PORT,username:password)");
+ }
+ else
+ {
+ var proxyCredPassword = proxyCred[1];
+
+ // if the password contains colon characters, re-stich them back into the password
+ for (int i = 2; i < proxyCred.Length - 1; i++)
+ {
+ proxyCredPassword += ":" + proxyCred[i];
+ }
+
+ myproxy.Credentials = new NetworkCredential(proxyCred[0], proxyCredPassword);
+ }
+ }
+
request.Proxy = myproxy;
break;
```