File tree Expand file tree Collapse file tree 2 files changed +39
-13
lines changed Expand file tree Collapse file tree 2 files changed +39
-13
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ use strict;
11
11
12
12
use Test::More;
13
13
14
+ use Socket qw/ CRLF / ;
15
+
14
16
BEGIN { use FindBin; chdir ($FindBin::Bin ); }
15
17
16
18
use lib ' lib' ;
@@ -21,7 +23,7 @@ use Test::Nginx;
21
23
select STDERR ; $| = 1;
22
24
select STDOUT ; $| = 1;
23
25
24
- my $t = Test::Nginx-> new()-> has(qw/ http proxy/ )-> plan(1 )
26
+ my $t = Test::Nginx-> new()-> has(qw/ http proxy/ )-> plan(2 )
25
27
-> write_file_expand(' nginx.conf' , <<"EOF" );
26
28
27
29
%%TEST_GLOBALS %%
@@ -70,4 +72,12 @@ $t->run();
70
72
like(http_get(' /' ), qr / x-authorization: AWS4.*Credential=my-access-key/ i ,
71
73
' awssig header' );
72
74
75
+ like(http(
76
+ ' GET / HTTP/1.0' . CRLF
77
+ . ' Foo: foo' . CRLF
78
+ . " Bar: \xFF\xFE\x80\x81 " . CRLF
79
+ . " Host: localhost" . CRLF . CRLF
80
+ ), qr / x-authorization: AWS4.*Credential=my-access-key/ ,
81
+ ' awssig invalid header ignored' );
82
+
73
83
# ##############################################################################
Original file line number Diff line number Diff line change @@ -465,20 +465,36 @@ impl<'a> Iterator for NgxListIterator<'a> {
465
465
type Item = ( & ' a str , & ' a str ) ;
466
466
467
467
fn next ( & mut self ) -> Option < Self :: Item > {
468
- let part = self . part . as_mut ( ) ?;
469
- if self . i >= part. arr . len ( ) {
470
- if let Some ( next_part_raw) = unsafe { part. raw . next . as_ref ( ) } {
471
- // loop back
472
- * part = next_part_raw. into ( ) ;
473
- self . i = 0 ;
474
- } else {
475
- self . part = None ;
476
- return None ;
468
+ loop {
469
+ let part = self . part . as_mut ( ) ?;
470
+ if self . i >= part. arr . len ( ) {
471
+ if let Some ( next_part_raw) = unsafe { part. raw . next . as_ref ( ) } {
472
+ // loop back
473
+ * part = next_part_raw. into ( ) ;
474
+ self . i = 0 ;
475
+ } else {
476
+ self . part = None ;
477
+ return None ;
478
+ }
479
+ }
480
+ let header = & part. arr [ self . i ] ;
481
+ self . i += 1 ;
482
+
483
+ let key_bytes = header. key . as_ref ( ) ;
484
+ let value_bytes = header. value . as_ref ( ) ;
485
+
486
+ match (
487
+ std:: str:: from_utf8 ( key_bytes) ,
488
+ std:: str:: from_utf8 ( value_bytes) ,
489
+ ) {
490
+ ( Ok ( key) , Ok ( value) ) => {
491
+ return Some ( ( key, value) ) ;
492
+ }
493
+ _ => {
494
+ continue ;
495
+ }
477
496
}
478
497
}
479
- let header = & part. arr [ self . i ] ;
480
- self . i += 1 ;
481
- Some ( ( header. key . to_str ( ) , header. value . to_str ( ) ) )
482
498
}
483
499
}
484
500
You can’t perform that action at this time.
0 commit comments