// grabbed from net/http.
161770
func parseRequestLine(line string) (method, uri, proto string, ok bool) {
	s1 := strings.Index(line, " ")
	s2 := strings.Index(line[s1+1:], " ")
	if s1 < 0 || s2 < 0 {
		return
	}
	s2 += s1 + 1
	return line[:s1], line[s1+1 : s2], line[s2+1:], true
}
757583
func (k *Kite) HandleHTTP(pattern string, handler http.Handler) {
	k.muxer.Handle(pattern, handler)
}
696748
func HTTPGet(uri string) ([]byte, error) {
	response, err := http.Get(uri)
	if err != nil {
		return nil, err
	}

	defer response.Body.Close()
	if response.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("http get error : uri=%v , statusCode=%v", uri, response.StatusCode)
	}
	return ioutil.ReadAll(response.Body)
}
874734
func (c *Client) get(url string) (string, error) {
	resp, err := http.Get(url)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()

	todo := new(Todo)
	if err = json.NewDecoder(resp.Body).Decode(todo); err != nil {
		return "", err
	}
	return todo.Task, nil
}
983220
func (statics *AssestStruct) HttpHandler(pdir string) http.Handler {
	return &_assestFileServer{sf: statics, pdir: pdir}
}
969483
func Http(ctx context.Context, w http.ResponseWriter) {
	if r := recover(); r != nil {
		outputPanic(ctx, r)
		http.Error(w, httpErrorMsg, http.StatusInternalServerError)
	}
}
460590
func from(req *http.Request) string {
	if f := req.Header.Get("X-Forwarded-For"); f != "" {
		return f
	}
	f := req.RemoteAddr
	ip, _, err := net.SplitHostPort(f)
	if err != nil {
		return f
	}
	return ip
}
98366
func (s *Server) HandleGetShortcut(c web.C, w http.ResponseWriter, r *http.Request) {
	shortcut := Shortcut{}
	err := s.Store.Get(fmt.Sprintf("/shortcuts/%s", c.URLParams["id"]), &shortcut)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	json.NewEncoder(w).Encode(shortcut)
}
1058335
func httpGetTenant(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetTenant: %+v", vars)

	key := vars["key"]

	collections.tenantMutex.Lock()
	defer collections.tenantMutex.Unlock()
	obj := collections.tenants[key]
	if obj == nil {
		log.Infof("tenant %s not found", key)
		return nil, errors.New("tenant not found")
	}

	// Return the obj
	return obj, nil
}
1059107
func ExtractHTTP(r *http.Request) propagation.Extractor {
	return func() (*model.SpanContext, error) {
		var (
			traceIDHeader      = r.Header.Get(TraceID)
			spanIDHeader       = r.Header.Get(SpanID)
			parentSpanIDHeader = r.Header.Get(ParentSpanID)
			sampledHeader      = r.Header.Get(Sampled)
			flagsHeader        = r.Header.Get(Flags)
		)

		return ParseHeaders(
			traceIDHeader, spanIDHeader, parentSpanIDHeader, sampledHeader,
			flagsHeader,
		)
	}
}
216424
func (self *Surf) httpRequest(param *Param) (resp *http.Response, err error) {
	req, err := http.NewRequest(param.method, param.url.String(), param.body)
	if err != nil {
		return nil, err
	}

	req.Header = param.header

	if param.tryTimes <= 0 {
		for {
			resp, err = param.client.Do(req)
			if err != nil {
				if !param.enableCookie {
					l := len(agent.UserAgents["common"])
					r := rand.New(rand.NewSource(time.Now().UnixNano()))
					req.Header.Set("User-Agent", agent.UserAgents["common"][r.Intn(l)])
				}
				time.Sleep(param.retryPause)
				continue
			}
			break
		}
	} else {
		for i := 0; i < param.tryTimes; i++ {
			resp, err = param.client.Do(req)
			if err != nil {
				if !param.enableCookie {
					l := len(agent.UserAgents["common"])
					r := rand.New(rand.NewSource(time.Now().UnixNano()))
					req.Header.Set("User-Agent", agent.UserAgents["common"][r.Intn(l)])
				}
				time.Sleep(param.retryPause)
				continue
			}
			break
		}
	}

	return resp, err
}
236370
func (bow *Browser) httpGET(u *url.URL, ref *url.URL) error {
	req, err := bow.buildRequest("GET", u.String(), ref, nil)
	if err != nil {
		return err
	}
	return bow.httpRequest(req)
}
468324
func httpGetHeader(h http.Header, key string) string {
	if h == nil {
		return ""
	}
	v := h[key]
	if len(v) == 0 {
		return ""
	}
	return v[0]
}
317445
func httpGetNetprofile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetNetprofile: %+v", vars)

	key := vars["key"]

	collections.netprofileMutex.Lock()
	defer collections.netprofileMutex.Unlock()
	obj := collections.netprofiles[key]
	if obj == nil {
		log.Infof("netprofile %s not found", key)
		return nil, errors.New("netprofile not found")
	}

	// Return the obj
	return obj, nil
}
1271568
func httpTraceAll(f http.HandlerFunc) http.HandlerFunc {
	if globalHTTPTraceFile == nil {
		return f
	}
	return httptracer.TraceReqHandlerFunc(f, globalHTTPTraceFile, true)
}
942607
func httpInspectBgp(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	var obj BgpInspect
	log.Debugf("Received httpInspectBgp: %+v", vars)

	key := vars["key"]

	collections.BgpMutex.Lock()
	defer collections.BgpMutex.Unlock()
	objConfig := collections.Bgps[key]
	if objConfig == nil {
		log.Errorf("Bgp %s not found", key)
		return nil, errors.New("Bgp not found")
	}
	obj.Config = *objConfig

	if err := GetOperBgp(&obj); err != nil {
		log.Errorf("GetBgp error for: %+v. Err: %v", obj, err)
		return nil, err
	}

	// Return the obj
	return &obj, nil
}
1256371
func (l *StringLexer) Grab(t ItemType) Item {
	// special case
	str := l.BufferString()
	line := l.line
	if len(str) > 0 && str[0] == '\n' {
		line--
	}
	return NewItem(t, l.start, line, str)
}