mirror of
https://github.com/soypat/lneto.git
synced 2026-08-19 22:24:03 +00:00
claude found neat bugs
This commit is contained in:
@@ -128,8 +128,6 @@ func (r *Router) Configure(cfg RouterConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Router) Handle(conn conn) error {
|
func (r *Router) Handle(conn conn) error {
|
||||||
r.mu.Lock()
|
|
||||||
defer r.mu.Unlock()
|
|
||||||
exch := r.getExch(conn)
|
exch := r.getExch(conn)
|
||||||
if exch == nil {
|
if exch == nil {
|
||||||
return lneto.ErrExhausted
|
return lneto.ErrExhausted
|
||||||
@@ -141,7 +139,9 @@ func (r *Router) Handle(conn conn) error {
|
|||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case r.pendingConns <- job{exch: exch}:
|
case r.pendingConns <- job{exch: exch}:
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
|
// pendingConns cannot store another Conn, we drop and return error.
|
||||||
exch.used.Store(false) // release.
|
exch.used.Store(false) // release.
|
||||||
}
|
}
|
||||||
return lneto.ErrPacketDrop
|
return lneto.ErrPacketDrop
|
||||||
@@ -286,6 +286,7 @@ func (exch *Exchange) Configure(rawbuf []byte, requestLim int, normalizeKeys boo
|
|||||||
if respSize < 0 {
|
if respSize < 0 {
|
||||||
panic("request lim larger than buffer")
|
panic("request lim larger than buffer")
|
||||||
}
|
}
|
||||||
|
exch.rawbuf = rawbuf
|
||||||
exch.reqHdr.Reset(rawbuf[:0:requestLim])
|
exch.reqHdr.Reset(rawbuf[:0:requestLim])
|
||||||
exch.normalizeKeys = normalizeKeys
|
exch.normalizeKeys = normalizeKeys
|
||||||
}
|
}
|
||||||
@@ -320,7 +321,7 @@ func (exch *Exchange) SetHeader(key, value string) (enoughMemory bool) {
|
|||||||
if exch.normalizeKeys {
|
if exch.normalizeKeys {
|
||||||
httpraw.NormalizeHeaderKey(exch.rawbuf[off : off+n])
|
httpraw.NormalizeHeaderKey(exch.rawbuf[off : off+n])
|
||||||
}
|
}
|
||||||
exch.rawbuf[n] = ':'
|
exch.rawbuf[off+n] = ':'
|
||||||
n++
|
n++
|
||||||
n += copy(exch.rawbuf[off+n:], value)
|
n += copy(exch.rawbuf[off+n:], value)
|
||||||
exch.rawbuf[off+n] = '\r'
|
exch.rawbuf[off+n] = '\r'
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ func CopyDecodedPercentURL(dst, value []byte, plusAsSpace bool) (n int, err erro
|
|||||||
func copyPlusDecoded(dst, src []byte, plusAsSpace bool) int {
|
func copyPlusDecoded(dst, src []byte, plusAsSpace bool) int {
|
||||||
n := copy(dst, src)
|
n := copy(dst, src)
|
||||||
if plusAsSpace {
|
if plusAsSpace {
|
||||||
for i := 0; i < n; i++ {
|
for i := range n {
|
||||||
if dst[i] == '+' {
|
if dst[i] == '+' {
|
||||||
dst[i] = ' '
|
dst[i] = ' '
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user