File tree 1 file changed +21
-7
lines changed
1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -1527,13 +1527,27 @@ impl proto::Peer for Peer {
1527
1527
// header
1528
1528
if let Some ( authority) = pseudo. authority {
1529
1529
let maybe_authority = uri:: Authority :: from_maybe_shared ( authority. clone ( ) . into_inner ( ) ) ;
1530
- parts. authority = Some ( maybe_authority. or_else ( |why| {
1531
- malformed ! (
1532
- "malformed headers: malformed authority ({:?}): {}" ,
1533
- authority,
1534
- why,
1535
- )
1536
- } ) ?) ;
1530
+
1531
+ // `:authority` is required only with `CONNECT` method.
1532
+ // It should contains host and port. This is exactly what `uri::Authority` is
1533
+ // going to parse.
1534
+ //
1535
+ // See: https://datatracker.ietf.org/doc/html/rfc7540#section-8.3
1536
+ if is_connect {
1537
+ if let Err ( why) = & maybe_authority {
1538
+ malformed ! (
1539
+ "malformed headers: malformed authority ({:?}): {}" ,
1540
+ authority,
1541
+ why,
1542
+ ) ;
1543
+ }
1544
+ }
1545
+
1546
+ // `authority` is not required in HTTP/2, so it is safe to keep it `None`
1547
+ // in `parts`.
1548
+ //
1549
+ // See: https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.3
1550
+ parts. authority = maybe_authority. ok ( ) ;
1537
1551
}
1538
1552
1539
1553
// A :scheme is required, except CONNECT.
You can’t perform that action at this time.
0 commit comments