Skip to content

Commit ee0be34

Browse files
committed
add content-length header in http2 when using Http2Stream.close
1 parent 5917746 commit ee0be34

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/kotlin/dev/samicpp/http/http2/Http2Streams.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,17 @@ class Http2Stream(val streamID:Int,val conn:Http2Connection):HttpSocket{
103103
override fun close(buffer:ByteArray){
104104
if(!closed){
105105
if(!sentHead&&compression==Compression.Gzip){
106+
val compressed=compressGzip(buffer)
106107
headers["content-encoding"]=mutableListOf("gzip")
108+
headers["content-length"]=mutableListOf(compressed.size.toString())
107109
sendHead()
108-
conn.sendData(streamID, compressGzip(buffer), true)
110+
conn.sendData(streamID, compressed, true)
109111
closed=true
110112
} else {
111-
if(!sentHead)sendHead()
113+
if(!sentHead){
114+
headers["content-length"]=mutableListOf(buffer.size.toString())
115+
sendHead()
116+
}
112117
conn.sendData(streamID, buffer, true)
113118
closed=true
114119
}

0 commit comments

Comments
 (0)