File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -170,11 +170,7 @@ where
170
170
) ) ) ;
171
171
}
172
172
}
173
- other_h2 @ Version :: HTTP_2 => {
174
- if self . config . ver != Ver :: Http2 {
175
- return ResponseFuture :: error_version ( other_h2) ;
176
- }
177
- }
173
+ Version :: HTTP_2 => ( ) ,
178
174
// completely unsupported HTTP version (like HTTP/0.9)!
179
175
other => return ResponseFuture :: error_version ( other) ,
180
176
} ;
@@ -230,6 +226,13 @@ where
230
226
let mut pooled = self . connection_for ( pool_key) . await ?;
231
227
232
228
if pooled. is_http1 ( ) {
229
+ if req. version ( ) == Version :: HTTP_2 {
230
+ warn ! ( "Connection is HTTP/1, but request requires HTTP/2" ) ;
231
+ return Err ( ClientError :: Normal (
232
+ crate :: Error :: new_user_unsupported_version ( ) ,
233
+ ) ) ;
234
+ }
235
+
233
236
if self . config . set_host {
234
237
let uri = req. uri ( ) . clone ( ) ;
235
238
req. headers_mut ( ) . entry ( HOST ) . or_insert_with ( || {
Original file line number Diff line number Diff line change @@ -2116,9 +2116,19 @@ mod dispatch_impl {
2116
2116
// so the unwrapped responses futures show it still worked.
2117
2117
assert_eq ! ( connects. load( Ordering :: SeqCst ) , 3 ) ;
2118
2118
2119
- let res4 = client. get ( url) ;
2119
+ let res4 = client. get ( url. clone ( ) ) ;
2120
2120
rt. block_on ( res4) . unwrap ( ) ;
2121
2121
2122
+ // HTTP/2 request allowed
2123
+ let res5 = client. request (
2124
+ Request :: builder ( )
2125
+ . uri ( url)
2126
+ . version ( hyper:: Version :: HTTP_2 )
2127
+ . body ( Default :: default ( ) )
2128
+ . unwrap ( ) ,
2129
+ ) ;
2130
+ rt. block_on ( res5) . unwrap ( ) ;
2131
+
2122
2132
assert_eq ! (
2123
2133
connects. load( Ordering :: SeqCst ) ,
2124
2134
3 ,
You can’t perform that action at this time.
0 commit comments