Skip to content

Commit 63adac8

Browse files
author
Yang Lyu
committed
Url match initial version
1 parent 8ce32dc commit 63adac8

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/Microsoft.VisualStudio.Web.BrowserLink/BrowserLinkMiddleWare.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ internal class BrowserLinkMiddleware
2525
private RequestDelegate _next;
2626
private string _applicationPath;
2727

28+
private static string _hostUrl;
29+
2830
internal BrowserLinkMiddleware(string applicationPath, RequestDelegate next)
2931
{
3032
_applicationPath = applicationPath;
@@ -39,14 +41,17 @@ internal Task Invoke(HttpContext context)
3941
string requestId = Guid.NewGuid().ToString("N");
4042

4143
IHttpSocketAdapter injectScriptSocket = GetSocketConnectionToHost(_applicationPath, requestId, "injectScriptLink", context.Request.IsHttps);
44+
RequestHeaders requestHeader = new RequestHeaders(context.Request.Headers);
4245

46+
_hostUrl = BrowserLinkMiddleWareUtil.GetRequestUrl(requestHeader);
47+
4348
if (injectScriptSocket != null)
4449
{
4550
return ExecuteWithFilter(injectScriptSocket, requestId, context);
4651
}
4752
else
4853
{
49-
RequestHeaders requestHeader = new RequestHeaders(context.Request.Headers);
54+
// RequestHeaders requestHeader = new RequestHeaders(context.Request.Headers);
5055

5156
if (requestHeader.IfNoneMatch != null && BrowserLinkMiddleWareUtil.GetRequestPort(requestHeader).Count != 0)
5257
{
@@ -172,6 +177,9 @@ private static void AddRequestHeaders(IHttpSocketAdapter httpSocket, string requ
172177
{
173178
httpSocket.AddRequestHeader(BrowserLinkConstants.RequestScheme, "http");
174179
}
180+
181+
httpSocket.AddRequestHeader(BrowserLinkConstants.RequestTest, "testValue");
182+
httpSocket.AddRequestHeader(BrowserLinkConstants.RequestHostUrl, _hostUrl);
175183
}
176184

177185
private static bool FindAndSignalHostConnection(string applicationPath)

src/Microsoft.VisualStudio.Web.BrowserLink/BrowserLinkMiddleWareUtil.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ internal static List<int> GetRequestPort(RequestHeaders requestHeader)
3232
return requestPortList;
3333
}
3434

35+
internal static string GetRequestUrl(RequestHeaders requstHeader)
36+
{
37+
return requstHeader.Host.ToString();
38+
}
39+
3540
internal static int GetCurrentPort(string connectionString)
3641
{
3742
Uri uri;

src/Microsoft.VisualStudio.Web.BrowserLink/Common/ArteryConstants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ internal static class BrowserLinkConstants
4848
/// </summary>
4949
public const string RequestScheme = "Scheme";
5050

51+
public const string RequestTest = "TestKey";
52+
53+
public const string RequestHostUrl = "HostUrl";
54+
5155
/// <summary>
5256
/// Suffix added to the end of the instance file name to identify a
5357
/// Version 2 instance file

0 commit comments

Comments
 (0)