Further improvements to httphi API (#173)

* add Exchange.WriteBodyString

* Mux.MaxPathValues and other improvements

* Mux PathValue improvemnt and fixes

* MuxSlice more method muxing improvements

* diagram out interesting approach to form parsing for clanker

* refactor RequestParseForm and achieve greatness in API design

* explicit naming of headerCapacityKV value in kvBuffer.Reset

* fix Mux bug not matching paths correctly; httpraw HTTP V1 naming applied

* rename many examples,use httphi in examples,remove useless maxAwaitingConn field

* add ipv4.String

* add ipv4 UnspecifiedAddr and BroadcastAddr

* add ethernet.String
This commit is contained in:
Pat Whittingslow
2026-07-31 12:47:33 -03:00
committed by GitHub
parent 5c54030f19
commit 1884cfc9b7
35 changed files with 2192 additions and 406 deletions
+9 -4
View File
@@ -23,6 +23,11 @@ func (kvb *kvBuffer) free() int { return cap(kvb.buf) - len(kvb.buf) }
// Stored pairs alias it, so writing to it mangles them.
func (kvb *kvBuffer) BufferRaw() []byte { return kvb.buf }
// BufferUsed returns the raw memory used, which is what a caller appending from
// several sources checks to know whether a separator is needed. Counts buffered
// bytes and not parsed pairs, so it is set before a Parse and unchanged by one.
func (kvb *kvBuffer) BufferUsed() int { return len(kvb.buf) }
// EnableBufferGrowth allows the buffer to grow past the memory [kvBuffer.Reset]
// was handed. The setting outlives Reset; with growth off callers get [ErrBufferExhausted].
func (kvb *kvBuffer) EnableBufferGrowth(enableGrowth bool) {
@@ -285,17 +290,17 @@ func (kvb *kvBuffer) getIdx(key string) int {
func (kvb *kvBuffer) getFoldIdx(key string) int {
for i, pair := range kvb.kvs {
if pair.isValid() && asciiEqualFold(key, b2s(kvb.AtKey(i))) {
if pair.isValid() && EqualFoldASCII(key, b2s(kvb.AtKey(i))) {
return i
}
}
return -1
}
// asciiEqualFold reports whether a and b are equal under ASCII case folding.
// EqualFoldASCII reports whether a and b are equal under ASCII case folding.
// Unlike strings.EqualFold it does not fold non-ASCII runes, so no multi-byte
// rune such as U+212A KELVIN SIGN can alias a header key.
func asciiEqualFold(a, b string) bool {
func EqualFoldASCII(a, b string) bool {
if len(a) != len(b) {
return false
}
@@ -463,7 +468,7 @@ func (pair pairKV) isValid() bool {
return pair.key.len > 0 || pair.value.len > 0
}
// isValidHeader is for the append-built [Header] store, where mustAppendSlice
// isValidHeader is for the append-built [HeaderV1] store, where mustAppendSlice
// burns byte 0 so a zero offset means absent. Drops offset-0 pairs otherwise.
func (pair pairKV) isValidHeader() bool { return pair.key.start > 0 }