@@ -37,17 +37,18 @@ internal BrowserLinkMiddleware(string applicationPath, RequestDelegate next)
3737 internal Task Invoke ( HttpContext context )
3838 {
3939 string requestId = Guid . NewGuid ( ) . ToString ( "N" ) ;
40+ RequestHeaders requestHeader = new RequestHeaders ( context . Request . Headers ) ;
4041
41- IHttpSocketAdapter injectScriptSocket = GetSocketConnectionToHost ( _applicationPath , requestId , "injectScriptLink" , context . Request . IsHttps ) ;
42+ string hostUrl = BrowserLinkMiddleWareUtil . GetRequestUrl ( requestHeader ) ;
4243
44+ IHttpSocketAdapter injectScriptSocket = GetSocketConnectionToHost ( _applicationPath , requestId , "injectScriptLink" , context . Request . IsHttps , hostUrl ) ;
45+
4346 if ( injectScriptSocket != null )
4447 {
4548 return ExecuteWithFilter ( injectScriptSocket , requestId , context ) ;
4649 }
4750 else
4851 {
49- RequestHeaders requestHeader = new RequestHeaders ( context . Request . Headers ) ;
50-
5152 if ( requestHeader . IfNoneMatch != null && BrowserLinkMiddleWareUtil . GetRequestPort ( requestHeader ) . Count != 0 )
5253 {
5354 BrowserLinkMiddleWareUtil . RemoveETagAndTimeStamp ( requestHeader ) ;
@@ -59,7 +60,11 @@ internal Task Invoke(HttpContext context)
5960
6061 private PageExecutionListenerFeature AddPageExecutionListenerFeatureTo ( HttpContext context , string requestId )
6162 {
62- 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 ) ;
6368
6469 if ( mappingDataSocket != null )
6570 {
@@ -126,7 +131,7 @@ private Task ExecuteWithoutFilter(HttpContext context)
126131 return _next ( context ) ;
127132 }
128133
129- 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 )
130135 {
131136 // The host should send an initial response immediately after
132137 // the connection is established. If it fails to do so multiple times,
@@ -148,7 +153,7 @@ private static IHttpSocketAdapter GetSocketConnectionToHost(string applicationPa
148153 {
149154 IHttpSocketAdapter httpSocket = await HttpSocketAdapter . OpenHttpSocketAsync ( "GET" , new Uri ( connectionString , rpcMethod ) ) ;
150155
151- AddRequestHeaders ( httpSocket , requestId , isHttps ) ;
156+ AddRequestHeaders ( httpSocket , requestId , isHttps , hostUrl ) ;
152157
153158 return httpSocket ;
154159 }
@@ -160,7 +165,7 @@ private static IHttpSocketAdapter GetSocketConnectionToHost(string applicationPa
160165 return null ;
161166 }
162167
163- private static void AddRequestHeaders ( IHttpSocketAdapter httpSocket , string requestId , bool isHttps )
168+ private static void AddRequestHeaders ( IHttpSocketAdapter httpSocket , string requestId , bool isHttps , string hostUrl )
164169 {
165170 httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestIdHeaderName , requestId ) ;
166171
@@ -172,6 +177,8 @@ private static void AddRequestHeaders(IHttpSocketAdapter httpSocket, string requ
172177 {
173178 httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestScheme , "http" ) ;
174179 }
180+
181+ httpSocket . AddRequestHeader ( BrowserLinkConstants . RequestHostUrl , hostUrl ) ;
175182 }
176183
177184 private static bool FindAndSignalHostConnection ( string applicationPath )
0 commit comments