- Reorganize internal packages and overall project structure - Update imports and wiring to match the new layout - Separate HTTP parsing and streaming from the server package - Separate middleware from the server package - Separate session registry from the session package - Move HTTP, HTTPS, and TCP servers to the transport package - Session package no longer starts the TCP server directly - Server package no longer starts HTTP/HTTPS servers on initialization - Forwarder no longer handles accepting TCP requests - Move session details to the types package - HTTP/HTTPS initialization is now the responsibility of main
30 lines
610 B
Go
30 lines
610 B
Go
package stream
|
|
|
|
import "bytes"
|
|
|
|
func splitHeaderAndBody(data []byte, delimiterIdx int) ([]byte, []byte) {
|
|
headerByte := data[:delimiterIdx+len(DELIMITER)]
|
|
body := data[delimiterIdx+len(DELIMITER):]
|
|
return headerByte, body
|
|
}
|
|
|
|
func isHTTPHeader(buf []byte) bool {
|
|
lines := bytes.Split(buf, []byte("\r\n"))
|
|
|
|
startLine := string(lines[0])
|
|
if !requestLine.MatchString(startLine) && !responseLine.MatchString(startLine) {
|
|
return false
|
|
}
|
|
|
|
for _, line := range lines[1:] {
|
|
if len(line) == 0 {
|
|
break
|
|
}
|
|
colonIdx := bytes.IndexByte(line, ':')
|
|
if colonIdx <= 0 {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|