File tree Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ public async Task PageEventsResponse()
5757 Assert . False ( responses [ 0 ] . FromCache ) ;
5858 Assert . False ( responses [ 0 ] . FromServiceWorker ) ;
5959 Assert . NotNull ( responses [ 0 ] . Request ) ;
60+
61+ var remoteAddress = responses [ 0 ] . RemoteAddress ;
62+ // Either IPv6 or IPv4, depending on environment.
63+ Assert . True ( remoteAddress . IP == "[::1]" || remoteAddress . IP == "127.0.0.1" ) ;
64+ Assert . Equal ( TestConstants . Port , remoteAddress . Port ) ;
6065 }
6166
6267 [ Fact ]
@@ -254,6 +259,7 @@ public async Task ShouldSupportRedirects()
254259 var redirectChain = response . Request . RedirectChain ;
255260 Assert . Single ( redirectChain ) ;
256261 Assert . Contains ( "/foo.html" , redirectChain [ 0 ] . Url ) ;
262+ Assert . Equal ( TestConstants . Port , redirectChain [ 0 ] . Response . RemoteAddress . Port ) ;
257263 }
258264 }
259265}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ public async Task ShouldIntercept()
3737 } ;
3838 var response = await Page . GoToAsync ( TestConstants . EmptyPage ) ;
3939 Assert . True ( response . Ok ) ;
40+ Assert . Equal ( TestConstants . Port , response . RemoteAddress . Port ) ;
4041 }
4142
4243 [ Fact ]
Original file line number Diff line number Diff line change @@ -20,5 +20,9 @@ internal class ResponsePayload
2020 public bool FromServiceWorker { get ; set ; }
2121 [ JsonProperty ( "statusText" ) ]
2222 public string StatusText { get ; set ; }
23+ [ JsonProperty ( "remoteIPAddress" ) ]
24+ public string RemoteIPAddress { get ; set ; }
25+ [ JsonProperty ( "remotePort" ) ]
26+ public int RemotePort { get ; set ; }
2327 }
2428}
Original file line number Diff line number Diff line change 1+ namespace PuppeteerSharp
2+ {
3+ /// <summary>
4+ /// Remote server address.
5+ /// </summary>
6+ /// <seealso cref="Response.RemoteAddress"/>
7+ public class RemoteAddress
8+ {
9+ /// <summary>
10+ /// The IP address of the remote server.
11+ /// </summary>
12+ public string IP { get ; set ; }
13+ /// <summary>
14+ /// The port used to connect to the remote server.
15+ /// </summary>
16+ public int Port { get ; set ; }
17+ }
18+ }
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ namespace PuppeteerSharp
1414 public class Response
1515 {
1616 private readonly CDPSession _client ;
17- private bool _fromDiskCache ;
17+ private readonly bool _fromDiskCache ;
1818 private string _buffer ;
1919
2020 internal Response (
@@ -39,6 +39,12 @@ internal Response(
3939 }
4040 }
4141 SecurityDetails = responseMessage . SecurityDetails ;
42+ RemoteAddress = new RemoteAddress
43+ {
44+ IP = responseMessage . RemoteIPAddress ,
45+ Port = responseMessage . RemotePort
46+ } ;
47+
4248 BodyLoadedTaskWrapper = new TaskCompletionSource < bool > ( ) ;
4349 }
4450
@@ -86,7 +92,11 @@ internal Response(
8692 /// Contains the status text of the response (e.g. usually an "OK" for a success).
8793 /// </summary>
8894 /// <value>The status text.</value>
89- public string StatusText { get ; }
95+ public string StatusText { get ; }
96+ /// <summary>
97+ /// Remove server address.
98+ /// </summary>
99+ public RemoteAddress RemoteAddress { get ; }
90100 internal TaskCompletionSource < bool > BodyLoadedTaskWrapper { get ; }
91101 #endregion
92102
You can’t perform that action at this time.
0 commit comments