mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-03 22:47:47 +00:00
35 lines
734 B
Go
35 lines
734 B
Go
package http
|
|
|
|
import (
|
|
"bufio"
|
|
|
|
"golang.org/x/net/http/httpguts"
|
|
)
|
|
|
|
// msg is *Request or *Response.
|
|
func readTransfer(msg *Request, r *bufio.Reader) (err error) {
|
|
// TODO:
|
|
return nil
|
|
}
|
|
|
|
// Determine whether to hang up after sending a request and body, or
|
|
// receiving a response and body
|
|
// 'header' is the request headers
|
|
func shouldClose(major, minor int, header Header, removeCloseHeader bool) bool {
|
|
if major < 1 {
|
|
return true
|
|
}
|
|
|
|
conv := header["Connection"]
|
|
hasClose := httpguts.HeaderValuesContainsToken(conv, "close")
|
|
if major == 1 && minor == 0 {
|
|
return hasClose || !httpguts.HeaderValuesContainsToken(conv, "keep-alive")
|
|
}
|
|
|
|
if hasClose && removeCloseHeader {
|
|
header.Del("Connection")
|
|
}
|
|
|
|
return hasClose
|
|
}
|