id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c13200
{ return All(Timeouts{Dial: timeout, KeepAlive: keepAlive}) }
c13201
defineTimeouts(timeouts, ctx) h.Next(ctx) }) }
c13202
return &Request{ Context: ctx, Middleware: middleware.New(), } }
c13203
r.Middleware.UseParent(cli.Middleware) return r }
c13204
mux.New() r.Use(mx) return mx }
c13205
ctx.Request.Method = method h.Next(ctx) }) return r }
c13206
*Request { r.Use(url.URL(uri)) return r }
c13207
*Request { r.Use(url.BaseURL(uri)) return r }
c13208
*Request { r.Use(url.Path(path)) return r }
c13209
*Request { r.Use(url.AddPath(path)) return r }
c13210
*Request { r.Use(query.Set(name, value)) return r }
c13211
*Request { r.Use(query.Add(name, value)) return r }
c13212
*Request { r.Use(query.SetMap(params)) return r }
c13213
*Request { r.Use(headers.Del(name)) return r }
c13214
*Request { r.Use(body.Reader(reader)) return r }
c13215
*Request { r.Use(body.String(data)) return r }
c13216
*Request { r.Use(body.JSON(data)) return r }
c13217
*Request { r.Use(body.XML(data)) return r }
c13218
= true ctx := NewDispatcher(r).Dispatch() return buildResponse(ctx) }
c13219
*Request { r.Middleware.Use(p) return r }
c13220
*Request { r.Middleware.UseRequest(fn) return r }
c13221
*Request { r.Middleware.UseResponse(fn) return r }
c13222
*Request { r.Middleware.UseError(fn) return r }
c13223
*Request { r.Middleware.UseHandler(phase, fn) return r }
c13224
= r.Client req.Context = r.Context.Clone() req.Middleware = r.Middleware.Clone() return req }
c13225
http.ProxyFromEnvironment, Dial: dialer.Dial, TLSHandshakeTimeout: TLSHandshakeTimeout, } return transport }
c13226
ctx.Request.SetBasicAuth(username, password) h.Next(ctx) }) }
c13227
ctx.Request.Header.Set("Authorization", "Bearer "+token) h.Next(ctx) }) }
c13228
ctx.Request.Header.Set("Authorization", value) h.Next(ctx) }) }
c13229
} // Override the http.Client transport transport.DisableCompression = true ctx.Client.Transport = transport h.Next(ctx) }) }
c13230
ctx.Request.AddCookie(cookie) h.Next(ctx) }) }
c13231
Value: value} ctx.Request.AddCookie(cookie) h.Next(ctx) }) }
c13232
c.Handler) { for k, v := range cookies { cookie := &http.Cookie{Name: k, Value: v} ctx.Request.AddCookie(cookie) } h.Next(ctx) }) }
c13233
:= range cookies { ctx.Request.AddCookie(cookie) } h.Next(ctx) }) }
c13234
:= cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}) ctx.Client.Jar = jar h.Next(ctx) }) }
c13235
http.Client transport ctx.Client.Transport = transport h.Next(ctx) }) }
c13236
if !ok { // If using a custom transport, just ignore it h.Next(ctx) return } // Override the http.Client transport transport.TLSClientConfig = config ctx.Client.Transport = transport h.Next(ctx) }) }
c13237
ctx.Client.CheckRedirect = func(req *http.Request, pool []*http.Request) error { return redirectPolicy(opts, req, pool) } h.Next(ctx) }) }
c13238
return redirectPolicy(Options{Limit: limit}, req, pool) } h.Next(ctx) }) }
c13239
ctx.Error = err h.next(ctx) }
c13240
{ ctx.Stopped = true h.next(ctx) }
c13241
return } called = true fn(ctx) } }
c13242
{ if value, ok := servers[req.URL.Scheme]; ok { return url.Parse(value) } return http.ProxyFromEnvironment(req) } // Override the transport ctx.Client.Transport = transport h.Next(ctx) }) }
c13243
req.SetClient(c) return req }
c13244
req.Method("GET") return req }
c13245
req.Method("POST") return req }
c13246
req.Method("PUT") return req }
c13247
req.Method("DELETE") return req }
c13248
req.Method("PATCH") return req }
c13249
req.Method("HEAD") return req }
c13250
ctx.Request.Method = name h.Next(ctx) }) return c }
c13251
*Client { c.Use(url.URL(uri)) return c }
c13252
*Client { c.Use(url.BaseURL(uri)) return c }
c13253
*Client { c.Use(url.Path(path)) return c }
c13254
*Client { c.Middleware.Use(p) return c }
c13255
*Client { c.Middleware.UseRequest(fn) return c }
c13256
*Client { c.Middleware.UseResponse(fn) return c }
c13257
*Client { c.Middleware.UseError(fn) return c }
c13258
*Client { c.Middleware.UseHandler(phase, fn) return c }
c13259
c.Context.UseParent(parent.Context) c.Middleware.UseParent(parent.Middleware) return c }
c13260
data := FormData{Files: []FormFile{file}} handle(ctx, h, data) }) }
c13261
*c.Context, h c.Handler) { data := FormData{Files: files} handle(ctx, h, data) }) }
c13262
c.Handler) { handle(ctx, h, data) }) }
c13263
handler context.HandlerFunc) { p.Handlers[phase] = handler }
c13264
nil { fn = p.DefaultHandler } if fn == nil { h.Next(ctx) return } fn(ctx, h) }
c13265
&Layer{Handlers: Handlers{phase: handler}} }
c13266
= strconv.Itoa(code) + " " + http.StatusText(code) }
c13267
StringReader(body) res.ContentLength = int64(len(body)) }
c13268
&& b != nil { rc = ioutil.NopCloser(b) } return rc }
c13269
:= range headers { ctx.Request.Header.Set(k, v) } h.Next(ctx) }) }
c13270
defineType(name, ctx.Request) h.Next(ctx) }) }
c13271
return &Context{Request: req, Response: res, Client: cli} }
c13272
panic("invalid request context") } return store }
c13273
:= c.getStore() store[key] = value }
c13274
value } if c.Parent != nil { return c.Parent.Get(key) } return nil }
c13275
if num, ok := value.(int); ok { return num, ok } return 0, false }
c13276
} } if c.Parent != nil { return c.Parent.GetString(key) } return "" }
c13277
value := range c.Parent.GetAll() { buf[key] = value } } return buf }
c13278
c.Parent != nil { return c.Parent.Root() } return c }
c13279
req.WithContext(c.Request.Context()) }
c13280
c.CopyTo(ctx) res := new(http.Response) *res = *c.Response ctx.Response = res return ctx }
c13281
ctx := context.WithValue(context.Background(), Key, store) newCtx.Request = newCtx.Request.WithContext(ctx) }
c13282
ProtoMinor: 1, Proto: "HTTP/1.1", Header: make(http.Header), Body: utils.NopCloser(), } // Return shallow copy of Request with the new context return req.WithContext(emptyContext()) }
c13283
req, Header: make(http.Header), Body: utils.NopCloser(), } }
c13284
value) ctx.Request.URL.RawQuery = query.Encode() h.Next(ctx) }) }
c13285
ctx.Request.URL.RawQuery = "" h.Next(ctx) }) }
c13286
query.Set(k, v) } ctx.Request.URL.RawQuery = query.Encode() h.Next(ctx) }) }
c13287
return r.RawResponse.Body.Close() }
c13288
if charsetReader != nil { xmlDecoder.CharsetReader = charsetReader } defer r.Close() if err := xmlDecoder.Decode(&userStruct); err != nil && err != io.EOF { return err } return nil }
c13289
r.buffer.Len() == 0 { return nil } return r.buffer.Bytes() }
c13290
r.populateResponseByteBuffer() return r.buffer.String() }
c13291
range res.TransferEncoding { if te == "chunked" { return true } } return false }
c13292
trace.Record(client, span, done) if err != nil { return err } return <-done }
c13293
unit special is a // bit wonky, but it seems like the // right tool for the job here: err = client.TimeInMilliseconds(metric.Name, float64(metric.Value), tags, 1.0) } else { err = client.Histogram(metric.Name, float64(metric.Value), tags, 1.0) } case ssf.SSFSample_SET: err = client.Set(metri...
c13294
(*s3.PutObjectOutput, error)) { m.putObject = f }
c13295
protocol.WriteSSF(ds.output, span) if err != nil { if protocol.IsFramingError(err) { _ = ds.conn.Close() ds.conn = nil } } return err }
c13296
{ return err } } err := ds.buffer.Flush() if err != nil { // buffer is poisoned, and we have no idea if the // connection is still valid. We better reconnect. _ = ds.conn.Close() ds.conn = nil } return err }
c13297
return } // the server usually waits for this to return before finalizing the // response, so this part must be done asynchronously go s.ImportMetrics(span.Attach(ctx), jsonMetrics) }) }
c13298
if !reflect.DeepEqual(sentinel, metric) { // we have found at least one entry that is properly formed return true } } return false }
c13299
return true } _, ok := ri[name] return ok }