mirror of
https://github.com/soypat/lneto.git
synced 2026-08-20 22:49:11 +00:00
add http/httphi (#171)
* add http/httphi * begin adding httphi tests * claude found neat bugs * add low level Handle function and more tests * more tests, run go generate * add Hijacker-like functionality * improve locking and acquisition of Exchanges in reconfiguring * several bugfixes, add internal.IntLen, round up http-linux example with new router API * small nit * add benchmarks * add query handling * remove ForEach pattern, allocates in TinyGo * massive documentation push and code reordering in files * Router.Handle returns error after being torn down * run go fix * rework Mux interface to receive a string request path * add MethodFrom * minor doc nit * fail on incomplete staging * add raw buffer access * add streaming API distinct from Exchange * begin adding multipart form logic * finish rounding up multipart form parsing * remove status type * first Multipart approach * begin adding readMultiPart * add Exchange.ReadMultiparts reimagining of clanker slop * ai insists with backoffs * simplify clanker slop * apply go fix * add a pattern argument to Mux * explicit header key/value alloc and add ExchangeConfig * fix tests after excplicit header alloc change * fix examples * run go fix * expose rawsock as experimental package (will use for external benchmarks) * remove backoff from form parsing * @MDr164 suggestions get potential fixes * apply go fix * add examples * add README.md * fix rawsock tinygo implementation * apply @MDr164 various fixes * update documentation on ContentLength methods and fix bug in Form reset on empty body * fix tests * add fuzz tests * run go fix * io.ErrNoProgress on parsing form spin * run go fix * remove backoff assumption from Router * httphi.Handle rejects unsupported protocols * go format router.go * add kvbuffer * rewrite Cookie with KVBuffer * mid refactor of KVBuffer into Header * work on KVBuffer exhausted semantics * add Go's ServeMux Request.PathValue access semantics to Exchange, Mux and MuxSlice * add PathValue example * document all the things; improve req Query semantics; add Form.EnableBufferGrowth * unexport kvBuffer * add Exchange.PathValueAppend * use stdlib in example instead of rawsock * remove rawsock from http example * add darwin arch rawsock * fix example * rename Router.TeardownGoroutines to Shutdown matching http.Server.Shutdown * rename types and identifiers * @MDr164 Content-Type and Transfer-Encoding bug catches
This commit is contained in:
committed by
Patricio Whittingslow
parent
a3f2742abf
commit
5c54030f19
@@ -768,6 +768,11 @@ func httpBodyClass(contentType, body []byte) FieldClass {
|
||||
return FieldClassText
|
||||
}
|
||||
|
||||
// maxCapturedHeaderFields bounds the field table a captured HTTP header is
|
||||
// parsed into. Captures are read once and discarded, so the table is sized for
|
||||
// a realistic request rather than for whatever the capture happens to hold.
|
||||
const maxCapturedHeaderFields = 64
|
||||
|
||||
func (pc *PacketBreakdown) CaptureHTTP(dst []Frame, pkt []byte, bitOffset int) ([]Frame, error) {
|
||||
debuglog("pcap:http:start")
|
||||
const httpProtocol = "HTTP"
|
||||
@@ -777,10 +782,10 @@ func (pc *PacketBreakdown) CaptureHTTP(dst []Frame, pkt []byte, bitOffset int) (
|
||||
const asResponse = true
|
||||
const asRequest = false
|
||||
httpData := pkt[bitOffset/8:]
|
||||
pc.hdr.Reset(httpData)
|
||||
pc.hdr.Reset(httpData, maxCapturedHeaderFields)
|
||||
err := pc.hdr.Parse(asResponse)
|
||||
if err != nil {
|
||||
pc.hdr.Reset(httpData)
|
||||
pc.hdr.Reset(httpData, 0) // Field table already sized, reuse it.
|
||||
err = pc.hdr.Parse(asRequest) // try as request.
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -33,8 +33,9 @@ const _FieldClass_name = "undefinedsourcedestinationprotocolversiontypesizeflags
|
||||
var _FieldClass_index = [...]uint8{0, 9, 15, 26, 34, 41, 45, 49, 54, 68, 76, 83, 90, 94, 101, 112, 114, 123, 131}
|
||||
|
||||
func (i FieldClass) String() string {
|
||||
if i >= FieldClass(len(_FieldClass_index)-1) {
|
||||
idx := int(i) - 0
|
||||
if i < 0 || idx >= len(_FieldClass_index)-1 {
|
||||
return "FieldClass(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _FieldClass_name[_FieldClass_index[i]:_FieldClass_index[i+1]]
|
||||
return _FieldClass_name[_FieldClass_index[idx]:_FieldClass_index[idx+1]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user