id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c167700 | err := w.Write(u.FullURI())
return int64(n), err
} | |
c167701 | dstW,
}
w.zw = newWriter(&w.xw)
return w
} | |
c167702 |
stopCh: make(chan struct{}),
}
pc.c1.rCh = ch1
pc.c1.wCh = ch2
pc.c2.rCh = ch2
pc.c2.wCh = ch1
pc.c1.pc = pc
pc.c2.pc = pc
return pc
} | |
c167703 | {
case <-pc.stopCh:
default:
close(pc.stopCh)
}
pc.stopChLock.Unlock()
return nil
} | |
c167704 |
return time.Unix(startTimeUnix+int64(n), 0)
} | |
c167705 | &Request{}
}
return v.(*Request)
} | |
c167706 | &Response{}
}
return v.(*Response)
} | |
c167707 |
return cc.get().DoDeadline(req, resp, deadline)
} | |
c167708 | := time.Now().Add(timeout)
return cc.get().DoDeadline(req, resp, deadline)
} | |
c167709 | = DefaultLBClientTimeout
}
return cc.DoTimeout(req, resp, timeout)
} | |
c167710 | error {
s := &Server{
Handler: handler,
}
return s.Serve(ln)
} | |
c167711 | handler,
}
return s.ServeTLS(ln, certFile, keyFile)
} | |
c167712 | handler,
}
return s.ServeTLSEmbed(ln, certData, keyData)
} | |
c167713 | handler,
}
return s.ListenAndServe(addr)
} | |
c167714 | handler,
}
return s.ListenAndServeUNIX(addr, mode)
} | |
c167715 | handler,
}
return s.ListenAndServeTLS(addr, certFile, keyFile)
} | |
c167716 | handler,
}
return s.ListenAndServeTLSEmbed(addr, certData, keyData)
} | |
c167717 | }
go func() {
h(ctx)
ch <- struct{}{}
<-concurrencyCh
}()
ctx.timeoutTimer = initTimer(ctx.timeoutTimer, timeout)
select {
case <-ch:
case <-ctx.timeoutTimer.C:
ctx.TimeoutError(msg)
}
stopTimer(ctx.timeoutTimer)
}
} | |
c167718 | return nil
}
state := tlsConn.ConnectionState()
return &state
} | |
c167719 | ctx.LocalAddr(), ctx.RemoteAddr(), ctx.Request.Header.Method(), ctx.URI().FullURI())
} | |
c167720 | string) {
ctx.Response.Header.SetContentType(contentType)
} | |
c167721 | []byte) {
ctx.Response.Header.SetContentTypeBytes(contentType)
} | |
c167722 | return nil, err
}
fhh := mf.File[key]
if fhh == nil {
return nil, ErrMissingFile
}
return fhh[0], nil
} | |
c167723 |
// Reopen f for the code below.
f, err = fh.Open()
if err != nil {
return err
}
}
defer f.Close()
ff, err := os.Create(path)
if err != nil {
return err
}
defer ff.Close()
_, err = copyZeroAlloc(ff, f)
return err
} | |
c167724 | addr == nil {
return zeroTCPAddr
}
return addr
} | |
c167725 |
ctx.SetStatusCode(statusCode)
ctx.SetContentTypeBytes(defaultContentType)
ctx.SetBodyString(msg)
} | |
c167726 | ctx.SetContentType(contentType)
ctx.SetBody(body)
} | |
c167727 | ctx.SetContentType(contentType)
ctx.SetBodyString(body)
} | |
c167728 | nil {
return true
}
lastModified = lastModified.Truncate(time.Second)
return ifMod.Before(lastModified)
} | |
c167729 |
ctx.SetStatusCode(StatusNotFound)
ctx.SetBodyString("404 Page not found")
} | |
c167730 | error) {
ctx.Response.AppendBody(p)
return len(p), nil
} | |
c167731 | error) {
ctx.Response.AppendBodyString(s)
return len(s), nil
} | |
c167732 | {
ctx.logger.logger = ctx.s.logger()
}
return &ctx.logger
} | |
c167733 | = make(map[string]ServeHandler)
}
s.configTLS()
s.tlsConfig.NextProtos = append(s.tlsConfig.NextProtos, key)
s.nextProtos[key] = nph
} | |
c167734 | TCPListener: tcpln,
keepalivePeriod: s.TCPKeepalivePeriod,
})
}
}
return s.Serve(ln)
} | |
c167735 | remove unix socket file %q: %s", addr, err)
}
ln, err := net.Listen("unix", addr)
if err != nil {
return err
}
if err = os.Chmod(addr, mode); err != nil {
return fmt.Errorf("cannot chmod %#o for %q: %s", mode, addr, err)
}
return s.Serve(ln)
} | |
c167736 | TCPListener: tcpln,
keepalivePeriod: s.TCPKeepalivePeriod,
}, certFile, keyFile)
}
}
return s.ServeTLS(ln, certFile, keyFile)
} | |
c167737 | TCPListener: tcpln,
keepalivePeriod: s.TCPKeepalivePeriod,
}, certData, keyData)
}
}
return s.ServeTLSEmbed(ln, certData, keyData)
} | |
c167738 | errNoCertOrKeyProvided
}
s.tlsConfig.BuildNameToCertificate()
return s.Serve(
tls.NewListener(ln, s.tlsConfig),
)
} | |
c167739 | return errNoCertOrKeyProvided
}
s.tlsConfig.BuildNameToCertificate()
return s.Serve(
tls.NewListener(ln, s.tlsConfig),
)
} | |
c167740 | certData(%d) and keyData(%d): %s",
len(certData), len(keyData), err)
}
s.configTLS()
s.tlsConfig.Certificates = append(s.tlsConfig.Certificates, cert)
return nil
} | |
c167741 | s.writeFastError(c, StatusServiceUnavailable,
"The connection cannot be served because Server.Concurrency limit exceeded")
c.Close()
s.setState(c, StateClosed)
if time.Since(lastOverflowErrorTime) > time.Minute {
s.logger().Printf("The incoming connection cannot be served, because %d concurrent conn... | |
c167742 |
if open := atomic.LoadInt32(&s.open); open == 0 {
break
}
// This is not an optimal solution but using a sync.WaitGroup
// here causes data races as it's hard to prevent Add() to be called
// while Wait() is waiting.
time.Sleep(time.Millisecond * 100)
}
s.ln = nil
return nil
} | |
c167743 | {
return WriteGzipLevel(w, p, CompressDefaultCompression)
} | |
c167744 | := int(n)
if int64(nn) != n {
return 0, fmt.Errorf("too much data gunzipped: %d", n)
}
return nn, err
} | |
c167745 | {
w := &byteSliceWriter{dst}
_, err := WriteGunzip(w, src)
return w.b, err
} | |
c167746 | WriteDeflateLevel(w, p, CompressDefaultCompression)
} | |
c167747 | := int(n)
if int64(nn) != n {
return 0, fmt.Errorf("too much data inflated: %d", n)
}
return nn, err
} | |
c167748 | {
w := &byteSliceWriter{dst}
_, err := WriteInflate(w, src)
return w.b, err
} | |
c167749 | req.Header.SetRequestURI(requestURI)
req.parsedURI = false
} | |
c167750 | req.Header.SetRequestURIBytes(requestURI)
req.parsedURI = false
} | |
c167751 | req.SetRequestURIBytes(requestURI)
}
return req.Header.RequestURI()
} | |
c167752 | int(size64)
if int64(size) != size64 {
size = -1
}
resp.Header.SetLastModified(fileInfo.ModTime())
resp.SetBodyStream(f, size)
return nil
} | |
c167753 | = resp
return &resp.w
} | |
c167754 | = req
return &req.w
} | |
c167755 | resp.closeBodyStream()
if err != nil {
bodyBuf.SetString(err.Error())
}
}
return resp.bodyBytes()
} | |
c167756 | {
return WriteMultipartForm(w, req.multipartForm, req.multipartFormBoundary)
}
_, err := w.Write(req.bodyBytes())
return err
} | |
c167757 | err := copyZeroAlloc(w, resp.bodyStream)
resp.closeBodyStream()
return err
}
_, err := w.Write(resp.bodyBytes())
return err
} | |
c167758 | resp.bodyBuffer().WriteString(s)
} | |
c167759 |
bodyBuf.Reset()
bodyBuf.WriteString(body)
} | |
c167760 | nil {
if resp.keepBodyBuffer {
resp.body.Reset()
} else {
responseBodyPool.Put(resp.body)
resp.body = nil
}
}
} | |
c167761 | []byte) {
resp.ResetBody()
resp.bodyRaw = body
} | |
c167762 | resp.closeBodyStream()
resp.body = nil
}
} | |
c167763 |
req.closeBodyStream()
req.body = nil
}
} | |
c167764 | bb.SetString(err.Error())
}
}
resp.bodyRaw = nil
oldBody := bb.B
bb.B = body
return oldBody
} | |
c167765 | := copyZeroAlloc(bb, req.bodyStream)
req.closeBodyStream()
if err != nil {
bb.Reset()
bb.SetString(err.Error())
}
}
oldBody := bb.B
bb.B = body
return oldBody
} | |
c167766 | req.onlyMultipartForm() {
body, err := marshalMultipartForm(req.multipartForm, req.multipartFormBoundary)
if err != nil {
return []byte(err.Error())
}
return body
}
return req.bodyBytes()
} | |
c167767 |
req.closeBodyStream()
req.bodyBuffer().WriteString(s)
} | |
c167768 |
req.closeBodyStream()
req.bodyBuffer().SetString(body)
} | |
c167769 | != nil {
if req.keepBodyBuffer {
req.body.Reset()
} else {
requestBodyPool.Put(req.body)
req.body = nil
}
}
} | |
c167770 |
dst.bodyBuffer().Set(req.body.B)
} else if dst.body != nil {
dst.body.Reset()
}
} | |
c167771 | resp.body != nil {
dst.bodyBuffer().Set(resp.body.B)
} else if dst.body != nil {
dst.body.Reset()
}
} | |
c167772 | }
fh, err := fv.Open()
if err != nil {
return fmt.Errorf("cannot open form file %q (%q): %s", k, fv.Filename, err)
}
if _, err = copyZeroAlloc(vw, fh); err != nil {
return fmt.Errorf("error when copying form file %q (%q): %s", k, fv.Filename, err)
}
if err = fh.Close(); err != nil {
retu... | |
c167773 |
resp.SkipBody = false
resp.raddr = nil
resp.laddr = nil
} | |
c167774 | if err = resp.Header.Read(r); err != nil {
return err
}
}
if !resp.mustSkipBody() {
bodyBuf := resp.bodyBuffer()
bodyBuf.Reset()
bodyBuf.B, err = readBody(r, resp.Header.ContentLength(), maxBodySize, bodyBuf.B)
if err != nil {
return err
}
resp.Header.SetContentLength(len(bodyBuf.B))
}
return... | |
c167775 | return writeBufio(req, w)
} | |
c167776 | return writeBufio(resp, w)
} | |
c167777 | hasBody := !req.Header.ignoreBody()
if hasBody {
if len(body) == 0 {
body = req.postArgs.QueryString()
}
req.Header.SetContentLength(len(body))
}
if err = req.Header.Write(w); err != nil {
return err
}
if hasBody {
_, err = w.Write(body)
} else if len(body) > 0 {
return fmt.Errorf("non-zero body f... | |
c167778 | if err := resp.Header.Write(w); err != nil {
return err
}
if sendBody {
if _, err := w.Write(body); err != nil {
return err
}
}
return nil
} | |
c167779 | h.SetCanonical(strLastModified, h.bufKV.value)
} | |
c167780 | return peekArgStr(h.cookies, key)
} | |
c167781 | contentType = defaultContentType
}
return contentType
} | |
c167782 | = append(h.server[:0], server...)
} | |
c167783 | = append(h.server[:0], server...)
} | |
c167784 | h.host = append(h.host[:0], host...)
return h.host
}
}
// slow path.
h.parseRawHeaders()
return h.host
} | |
c167785 | h.host = append(h.host[:0], host...)
} | |
c167786 | h.host = append(h.host[:0], host...)
} | |
c167787 | h.userAgent = append(h.userAgent[:0], userAgent...)
} | |
c167788 | h.userAgent = append(h.userAgent[:0], userAgent...)
} | |
c167789 |
if len(h.method) == 0 {
return strGet
}
return h.method
} | |
c167790 | = append(h.method[:0], method...)
} | |
c167791 | = append(h.method[:0], method...)
} | |
c167792 | requestURI = strSlash
}
return requestURI
} | |
c167793 | = append(h.requestURI[:0], requestURI...)
} | |
c167794 | = append(h.requestURI[:0], requestURI...)
} | |
c167795 | acceptEncoding...)
return h.HasAcceptEncodingBytes(h.bufKV.value)
} | |
c167796 | if len(b) > 0 && b[0] != ',' {
return false
}
if n == 0 {
return true
}
return ae[n-1] == ' '
} | |
c167797 | v []byte) { n++ })
return n
} | |
c167798 | = false
h.noDefaultContentType = false
h.resetSkipNormalize()
} | |
c167799 | cookie.Key(), cookie.Cookie(), argsHasValue)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.