File tree Expand file tree Collapse file tree 3 files changed +56
-3
lines changed 
PuppeteerSharp.Tests/Issues Expand file tree Collapse file tree 3 files changed +56
-3
lines changed Original file line number Diff line number Diff line change 1+ using  Microsoft . AspNetCore . Http ; 
2+ using  System ; 
3+ using  System . Collections . Generic ; 
4+ using  System . IO ; 
5+ using  System . Linq ; 
6+ using  System . Net ; 
7+ using  System . Net . Http ; 
8+ using  System . Text ; 
9+ using  System . Threading . Tasks ; 
10+ using  Xunit ; 
11+ using  Xunit . Abstractions ; 
12+ 
13+ namespace  PuppeteerSharp . Tests . Issues 
14+ { 
15+     [ Collection ( "PuppeteerLoaderFixture collection" ) ] 
16+     public  class  Issue0616  :  PuppeteerPageBaseTest 
17+     { 
18+         public  Issue0616 ( ITestOutputHelper  output )  :  base ( output ) 
19+         { 
20+         } 
21+ 
22+         [ Fact ] 
23+         public  async  Task  ShouldBeAbleToChangeToPost ( ) 
24+         { 
25+             await  Page . SetRequestInterceptionAsync ( true ) ; 
26+             Page . Request  +=  async  ( sender ,  e )  => 
27+             { 
28+                 var  payload  =  new  Payload ( ) 
29+                 { 
30+                     Method  =  HttpMethod . Post , 
31+                     PostData  =  "foo" 
32+                 } ; 
33+                 await  e . Request . ContinueAsync ( payload ) ; 
34+             } ; 
35+ 
36+             Server . SetRoute ( "/grid.html" ,  async  ( context )  => 
37+             { 
38+                 using  ( var  reader  =  new  StreamReader ( context . Request . Body ,  Encoding . UTF8 ) ) 
39+                 { 
40+                     var  request  =  await  reader . ReadToEndAsync ( ) ; 
41+                     await  context . Response . WriteAsync ( request ) ; 
42+                 } 
43+             } ) ; 
44+             var  response  =  await  Page . GoToAsync ( TestConstants . ServerUrl  +  "/grid.html" ) ; 
45+ 
46+             Assert . Equal ( TestConstants . ServerUrl  +  "/grid.html" ,  response . Url ) ; 
47+             Assert . Equal ( "foo" ,  await  response . TextAsync ( ) ) ; 
48+         } 
49+     } 
50+ } 
Original file line number Diff line number Diff line change @@ -13,7 +13,10 @@ namespace PuppeteerSharp
1313    /// </summary> 
1414    public  class  Payload 
1515    { 
16-         internal  Payload ( ) 
16+         /// <summary> 
17+         /// Initializes a new instance of the <see cref="PuppeteerSharp.Payload"/> class. 
18+         /// </summary> 
19+         public  Payload ( ) 
1720        { 
1821            Headers  =  new  Dictionary < string ,  object > ( ) ; 
1922        } 
Original file line number Diff line number Diff line change @@ -180,15 +180,15 @@ public async Task ContinueAsync(Payload overrides = null)
180180
181181                if  ( overrides ? . Method  !=  null ) 
182182                { 
183-                     requestData [ "method" ]  =  overrides . Method ; 
183+                     requestData [ "method" ]  =  overrides . Method . ToString ( ) ; 
184184                } 
185185
186186                if  ( overrides ? . PostData  !=  null ) 
187187                { 
188188                    requestData [ "postData" ]  =  overrides . PostData ; 
189189                } 
190190
191-                 if  ( overrides ? . Headers   !=   null ) 
191+                 if  ( overrides ? . Headers ? . Count   >   0 ) 
192192                { 
193193                    requestData [ "headers" ]  =  overrides . Headers ; 
194194                } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments