File tree 3 files changed +40
-0
lines changed
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -513,6 +513,32 @@ func TestRequestWriteBufferedWriter(t *testing.T) {
513
513
}
514
514
}
515
515
516
+ func TestStarRequest (t * testing.T ) {
517
+ req , err := ReadRequest (bufio .NewReader (strings .NewReader ("M-SEARCH * HTTP/1.1\r \n \r \n " )))
518
+ if err != nil {
519
+ return
520
+ }
521
+ var out bytes.Buffer
522
+ if err := req .Write (& out ); err != nil {
523
+ t .Fatal (err )
524
+ }
525
+ back , err := ReadRequest (bufio .NewReader (& out ))
526
+ if err != nil {
527
+ t .Fatal (err )
528
+ }
529
+ // Ignore the Headers (the User-Agent breaks the deep equal,
530
+ // but we don't care about it)
531
+ req .Header = nil
532
+ back .Header = nil
533
+ if ! reflect .DeepEqual (req , back ) {
534
+ t .Errorf ("Original request doesn't match Request read back." )
535
+ t .Logf ("Original: %#v" , req )
536
+ t .Logf ("Original.URL: %#v" , req .URL )
537
+ t .Logf ("Wrote: %s" , out .Bytes ())
538
+ t .Logf ("Read back (doesn't match Original): %#v" , back )
539
+ }
540
+ }
541
+
516
542
func testMissingFile (t * testing.T , req * Request ) {
517
543
f , fh , err := req .FormFile ("missing" )
518
544
if f != nil {
Original file line number Diff line number Diff line change @@ -537,6 +537,9 @@ func (u *URL) EscapedPath() string {
537
537
return u .RawPath
538
538
}
539
539
}
540
+ if u .Path == "*" {
541
+ return "*" // don't escape (Issue 11202)
542
+ }
540
543
return escape (u .Path , encodePath )
541
544
}
542
545
Original file line number Diff line number Diff line change @@ -1107,6 +1107,17 @@ func TestParseAuthority(t *testing.T) {
1107
1107
}
1108
1108
}
1109
1109
1110
+ // Issue 11202
1111
+ func TestStarRequest (t * testing.T ) {
1112
+ u , err := Parse ("*" )
1113
+ if err != nil {
1114
+ t .Fatal (err )
1115
+ }
1116
+ if got , want := u .RequestURI (), "*" ; got != want {
1117
+ t .Errorf ("RequestURI = %q; want %q" , got , want )
1118
+ }
1119
+ }
1120
+
1110
1121
type shouldEscapeTest struct {
1111
1122
in byte
1112
1123
mode encoding
You can’t perform that action at this time.
0 commit comments