@@ -25,8 +25,6 @@ internal class BrowserLinkMiddleware
2525 private RequestDelegate _next ;
2626 private string _applicationPath ;
2727
28- private static string _hostUrl ;
29-
3028 internal BrowserLinkMiddleware ( string applicationPath , RequestDelegate next )
3129 {
3230 _applicationPath = applicationPath ;
@@ -39,20 +37,18 @@ internal BrowserLinkMiddleware(string applicationPath, RequestDelegate next)
3937 internal Task Invoke ( HttpContext context )
4038 {
4139 string requestId = Guid . NewGuid ( ) . ToString ( "N" ) ;
42-
43- IHttpSocketAdapter injectScriptSocket = GetSocketConnectionToHost ( _applicationPath , requestId , "injectScriptLink" , context . Request . IsHttps ) ;
4440 RequestHeaders requestHeader = new RequestHeaders ( context . Request . Headers ) ;
4541
46- _hostUrl = BrowserLinkMiddleWareUtil . GetRequestUrl ( requestHeader ) ;
47-
42+ string hostUrl = BrowserLinkMiddleWareUtil . GetRequestUrl ( requestHeader ) ;
43+
44+ IHttpSocketAdapter injectScriptSocket = GetSocketConnectionToHost ( _applicationPath , requestId , "injectScriptLink" , context . Request . IsHttps , hostUrl ) ;
45+
4846 if ( injectScriptSocket != null )
4947 {
5048 return ExecuteWithFilter ( injectScriptSocket , requestId , context ) ;
5149 }
5250 else
5351 {
54- // RequestHeaders requestHeader = new RequestHeaders(context.Request.Headers);
55-
5652 if ( requestHeader . IfNoneMatch != null && BrowserLinkMiddleWareUtil . GetRequestPort ( requestHeader ) . Count != 0 )
5753 {
5854 BrowserLinkMiddleWareUtil . RemoveETagAndTimeStamp ( requestHeader ) ;
@@ -64,7 +60,11 @@ internal Task Invoke(HttpContext context)
6460
6561 private PageExecutionListenerFeature AddPageExecutionListenerFeatureTo ( HttpContext context , string requestId )
6662 {
67- IHttpSocketAdapter mappingDataSocket = GetSocketConnectionToHost ( _applicationPath , requestId , "sendMappingData" , context . Request . IsHttps ) ;
63+ RequestHeaders requestHeader = new RequestHeaders ( context . Request . Headers ) ;
64+
65+ string hostUrl = BrowserLinkMiddleWareUtil . GetRequestUrl ( requestHeader ) ;
66+
67+ IHttpSocketAdapter mappingDataSocket = GetSocketConnectionToHost ( _applicationPath , requestId , "sendMappingData" , context . Request . IsHttps , hostUrl ) ;
6868
6969 if ( mappingDataSocket != null )
7070 {
@@ -131,7 +131,7 @@ private Task ExecuteWithoutFilter(HttpContext context)
131131 return _next ( context ) ;
132132 }
133133
134- private static IHttpSocketAdapter GetSocketConnectionToHost ( string applicationPath , string requestId , string rpcMethod , bool isHttps )
134+ private static IHttpSocketAdapter GetSocketConnectionToHost ( string applicationPath , string requestId , string rpcMethod , bool isHttps , string hostUrl )
135135 {
136136 // The host should send an initial response immediately after
137137 // the connection is established. If it fails to do so multiple times,
@@ -153,7 +153,7 @@ private static IHttpSocketAdapter GetSocketConnectionToHost(string applicationPa
153153 {
154154 IHttpSocketAdapter httpSocket = await HttpSocketAdapter . OpenHttpSocketAsync ( "GET" , new Uri ( connectionString , rpcMethod ) ) ;
155155
156- AddRequestHeaders ( httpSocket , requestId , isHttps ) ;
156+ AddRequestHeaders ( httpSocket , requestId , isHttps , hostUrl ) ;
157157
158158 return httpSocket ;
159159 }
@@ -165,7 +165,7 @@ private static IHttpSocketAdapter GetSocketConnectionToHost(string applicationPa
165165 return null ;
166166 }
167167
168- private static void AddRequestHeaders ( IHttpSocketAdapter httpSocket , string requestId , bool isHttps )
168+ private static void AddRequestHeaders ( IHttpSocketAdapter httpSocket , string requestId , bool isHttps , string hostUrl )
169169 {
170170 httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestIdHeaderName , requestId ) ;
171171
@@ -178,8 +178,7 @@ private static void AddRequestHeaders(IHttpSocketAdapter httpSocket, string requ
178178 httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestScheme , "http" ) ;
179179 }
180180
181- httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestTest , "testValue" ) ;
182- httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestHostUrl , _hostUrl ) ;
181+ httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestHostUrl , hostUrl ) ;
183182 }
184183
185184 private static bool FindAndSignalHostConnection ( string applicationPath )
0 commit comments