This repository was archived by the owner on Jul 9, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed
examples/Titanium.Web.Proxy.Examples.Wpf
src/Titanium.Web.Proxy/Http Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ public void Update(SessionEventArgsBase args)
146146 var response = HttpClient . Response ;
147147 int statusCode = response ? . StatusCode ?? 0 ;
148148 StatusCode = statusCode == 0 ? "-" : statusCode . ToString ( ) ;
149- Protocol = request . RequestUri . Scheme ;
149+ Protocol = request . HttpVersion . Major == 2 ? "http2" : request . RequestUri . Scheme ;
150150 ClientConnectionId = args . ClientConnectionId ;
151151 ServerConnectionId = args . ServerConnectionId ;
152152
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ public static class KnownHeaders
1111 public static KnownHeader ConnectionKeepAlive = "keep-alive" ;
1212
1313 public static KnownHeader ContentLength = "Content-Length" ;
14+ public static KnownHeader ContentLengthHttp2 = "content-length" ;
1415
1516 public static KnownHeader ContentType = "Content-Type" ;
1617 public static KnownHeader ContentTypeCharset = "charset" ;
@@ -48,4 +49,4 @@ public static class KnownHeaders
4849 public static KnownHeader TransferEncoding = "Transfer-Encoding" ;
4950 public static KnownHeader TransferEncodingChunked = "chunked" ;
5051 }
51- }
52+ }
Original file line number Diff line number Diff line change @@ -105,7 +105,10 @@ public long ContentLength
105105 {
106106 if ( value >= 0 )
107107 {
108- Headers . SetOrAddHeaderValue ( KnownHeaders . ContentLength , value . ToString ( ) ) ;
108+ Headers . SetOrAddHeaderValue (
109+ HttpVersion >= HttpHeader . Version20
110+ ? KnownHeaders . ContentLengthHttp2
111+ : KnownHeaders . ContentLength , value . ToString ( ) ) ;
109112 IsChunked = false ;
110113 }
111114 else
Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ public override bool HasBody
6666 return true ;
6767 }
6868
69+ if ( ContentLength == - 1 && HttpVersion == HttpHeader . Version20 )
70+ {
71+ return true ;
72+ }
73+
6974 // has response if connection:keep-alive header exist and when version is http/1.0
7075 // Because in Http 1.0 server can return a response without content-length (expectation being client would read until end of stream)
7176 if ( KeepAlive && HttpVersion == HttpHeader . Version10 )
You can’t perform that action at this time.
0 commit comments