http.go 341 B

1234567891011121314151617181920
  1. package l7
  2. import (
  3. "bytes"
  4. )
  5. func ParseHttp(payload []byte) (string, string) {
  6. method, rest, ok := bytes.Cut(payload, space)
  7. if !ok {
  8. return "", ""
  9. }
  10. if !isHttpMethod(string(method)) {
  11. return "", ""
  12. }
  13. uri, _, ok := bytes.Cut(rest, space)
  14. if !ok {
  15. uri = append(uri, []byte("...")...)
  16. }
  17. return string(method), string(uri)
  18. }