// submitRequest sends a request for either enabling or disabling a particular
// outpoint and awaits an error response. The request type is dictated by the
// reqChan passed in, which can be either of the enableRequests or
// disableRequests channels.
10911
func (m *ChanStatusManager) submitRequest(reqChan chan statusRequest,
	outpoint wire.OutPoint) error {

	req := statusRequest{
		outpoint: outpoint,
		errChan:  make(chan error, 1),
	}

	select {
	case reqChan <- req:
	case <-m.quit:
		return ErrChanStatusManagerExiting
	}

	select {
	case err := <-req.errChan:
		return err
	case <-m.quit:
		return ErrChanStatusManagerExiting
	}
}
518714
func (r *redisPubSubRequester) Request() error {
	if err := r.publishConn.Send("PUBLISH", r.channel, r.msg); err != nil {
		return err
	}
	if err := r.publishConn.Flush(); err != nil {
		return err
	}
	switch recv := r.subscribeConn.Receive().(type) {
	case error:
		return recv
	default:
		return nil
	}
}
1118249
func (c *Client) DoRequest(r *Request) (*http.Response, error) {
	req, err := r.toHTTP()
	if err != nil {
		return nil, err
	}
	return c.Do(req)
}
503834
func (r *redisRequester) Request() error {
	_, err := r.conn.Do(r.command, r.args...)
	return err
}
167460
func (n *natsRequester) Request() error {
	if err := n.conn.Publish(n.subject, n.msg); err != nil {
		return err
	}
	_, err := n.sub.NextMsg(30 * time.Second)
	return err
}
539872
func (cli *OpsGenieClient) sendRequest(req goreq.Request) (*goreq.Response, error) {
	// send the request
	var resp *goreq.Response
	var err error
	for i := 0; i < cli.httpTransportSettings.MaxRetryAttempts; i++ {
		resp, err = req.Do()
		if err == nil && resp.StatusCode < 500 {
			break
		}
		if resp != nil {
			defer resp.Body.Close()
			logging.Logger().Info(fmt.Sprintf("Retrying request [%s] ResponseCode:[%d]. RetryCount: %d", req.Uri, resp.StatusCode, (i + 1)))
		} else {
			logging.Logger().Info(fmt.Sprintf("Retrying request [%s] Reason:[%s]. RetryCount: %d", req.Uri, err.Error(), (i + 1)))
		}
		time.Sleep(timeSleepBetweenRequests * time.Duration(i+1))
	}
	if err != nil {
		message := "Unable to send the request " + err.Error()
		logging.Logger().Warn(message)
		return nil, errors.New(message)
	}
	// check for the returning http status
	statusCode := resp.StatusCode
	if statusCode >= 400 {
		body, err := resp.Body.ToString()
		if err != nil {
			message := "Server response with error can not be parsed " + err.Error()
			logging.Logger().Warn(message)
			return nil, errors.New(message)
		}
		return nil, errorMessage(statusCode, body)
	}
	return resp, nil
}
798850
func (n *Nats) Request(subject string, data PayloadWithContext, responsePtr interface{}, timeout time.Duration) error {
	dead := time.Now().Add(timeout)
	n.updateContext(data, RequestType_REQ, &dead)
	return n.EncCon.Request(subject, data, responsePtr, timeout)
}
339443
func (client *Client) ParseRequest(r *http.Request) ([]*Event, error) {
	return ParseRequest(client.channelSecret, r)
}
1324604
func (s *IndicesAnalyzeService) Request(request *IndicesAnalyzeRequest) *IndicesAnalyzeService {
	if request == nil {
		s.request = new(IndicesAnalyzeRequest)
	} else {
		s.request = request
	}
	return s
}
491404
func (c *cassandraRequester) Request() error {
	return c.session.Query(c.statement, c.values...).Exec()
}
143448
func (c *EncodedConn) PublishRequest(subject, reply string, v interface{}) error {
	b, err := c.Enc.Encode(subject, v)
	if err != nil {
		return err
	}
	return c.Conn.publish(subject, reply, b)
}
828535
func (c *Config) HandleRequest(w http.ResponseWriter, r *http.Request) {
	requestOrigin := r.Header.Get(originKey)
	if requestOrigin == "" {
		return
	}

	//check origin against allowed origins
	for _, ao := range c.AllowedOrigins {
		if ao == "*" || ao == requestOrigin {
			responseOrigin := "*"
			if ao != "*" {
				responseOrigin = requestOrigin
			}
			addAllowOriginHeader(w, responseOrigin)
			break
		}
	}

	if w.Header().Get(allowOriginKey) == "" {
		if c.anyOriginRegexpMatch(requestOrigin) {
			addAllowOriginHeader(w, requestOrigin)
		} else {
			return //if we didn't set a valid allow-origin, none of the other headers matter
		}
	}

	if IsPreflight(r) {
		w.Header().Set(allowMethodsKey, c.AllowedMethods)
		if c.AllowedHeaders != "" {
			if c.AllowedHeaders != "*" {
				w.Header().Set(allowHeadersKey, c.AllowedHeaders)
			} else {
				w.Header().Set(allowHeadersKey, r.Header.Get(requestHeadersKey))
			}

		}
		if c.MaxAge > 0 {
			w.Header().Set(maxAgeKey, fmt.Sprint(c.MaxAge))
		}
	} else {
		//regular request
		if c.ExposedHeaders != "" {
			w.Header().Set(exposeHeadersKey, c.ExposedHeaders)
		}
	}

	if c.AllowCredentials != nil {
		w.Header().Set(allowCredentialsKey, fmt.Sprint(*c.AllowCredentials))
	}

}
124591
func (c *Client) sendRequest(request *soap.SoapMessage) (string, error) {
	return c.http.Post(c, request)
}
148010
func AllowRequestsFrom(allowedOrigins ...string) http.HandlerFunc {
	c := &CORS{
		AllowOrigins: allowedOrigins,
		AllowMethods: []string{"GET", "POST"},
		AllowHeaders: []string{"Origin", "Content-Type"},
		ContentType:  "application/json; charset=utf-8",
	}

	c.generatePatterns()

	return func(w http.ResponseWriter, req *http.Request) {
		origin := req.Header.Get("Origin")
		if c.isOriginAllowed(origin) {
			w.Header().Set("Access-Control-Allow-Origin", origin)
			w.Header().Set("Access-Control-Allow-Headers", c.AllowedHeaders())
			w.Header().Set("Access-Control-Allow-Methods", c.AllowedMethods())
			w.Header().Set("Content-Type", c.ContentType)
		}
	}
}
748111
func (p DebugPrinter) Request(req *http.Request) {
	if req == nil {
		return
	}

	dump, err := httputil.DumpRequest(req, p.body)
	if err != nil {
		panic(err)
	}
	p.logger.Logf("%s", dump)
}
546367
func (c *HTTPClient) doRequest(req *http.Request) (resp *http.Response, err error) {
	debugRequest(req) //DEBUG
	req.SetBasicAuth(c.apiKeyPublic, c.apiKeyPrivate)
	for attempt := 0; attempt < NbAttempt; attempt++ {
		if resp != nil {
			resp.Body.Close()
		}
		resp, err = c.client.Do(req)
		if err != nil || (resp != nil && resp.StatusCode != 500) {
			break
		}
	}
	defer debugResponse(resp) //DEBUG
	if err != nil {
		return resp, fmt.Errorf("Error getting %s: %s", req.URL, err)
	}
	err = checkResponseError(resp)
	return resp, err
}
108806
func HTTPRequest(url string, method string, body io.Reader, headers map[string]string, failOnError bool) (*HTTPResponse, error) {
	c := &HTTPRequestConfig{
		URL:            url,
		Method:         method,
		Body:           body,
		Headers:        headers,
		FailOnError:    failOnError,
		TimeoutSeconds: 30,
	}
	return HTTPComplexRequest(c)
}