// GetRequester returns a new Requester, called for each Benchmark connection.
331540
func (c *CassandraRequesterFactory) GetRequester(uint64) bench.Requester {
	return &cassandraRequester{
		urls:        c.URLs,
		keyspace:    c.Keyspace,
		consistency: c.Consistency,
		statement:   c.Statement,
		values:      c.Values,
	}
}
112551
func (a *AuthServerCodec) ReadRequestHeader(r *rpc.Request) error {

	// There is no need for synchronization here, since go's RPC server
	//  ensures that requests are read one-at-a-time

	// Reset state
	a.lastError = nil
	a.buff.ReadBuff.Reset()

	ident, body, err := a.parser.ReadHeader(a.conn)
	if err != nil {
		log.WithError(err).WithField("ServiceMethod", r.ServiceMethod).Debug("Could not authenticate RPC request")
		if e, ok := err.(*auth.AuthHeaderError); ok {
			body = e.Payload
			a.lastError = e.Err
		} else {
			return err
		}
	}

	// Now write the actual request to the buffer
	if _, err = a.buff.ReadBuff.Write(body); err != nil {
		return err
	}

	// Let the underlying codec read the request from the buffer and parse it
	if err := a.wrappedcodec.ReadRequestHeader(r); err != nil {
		return err
	}

	log.WithField("ServiceMethod", r.ServiceMethod).Debug("Received RPC request")

	// Now we can get the method name from r and authenticate if required
	//  If this fails, save the error to return later
	//  If we return an error now, the server will simply close the connection
	//  This is safe because go's rpc server always calls ReadRequestHeader and ReadRequestBody back-to-back
	//   (unless ReadRequestHeader returns an error)
	if requiresAuthentication(r.ServiceMethod) {
		if a.lastError == nil {
			if requiresAdmin(r.ServiceMethod) && (ident == nil || !ident.HasAdminAccess()) {
				log.WithField("ServiceMethod", r.ServiceMethod).Debug("Received unauthorized RPC request")
				a.lastError = ErrNoAdmin
			}
		}
		//TODO: save the identity so we can inject it into the request body later
	}
	return nil
}
1361635
func (b *Bucket) GetObjectRequest(key string, opts ...option.GetObjectInput) (*request.Request, *s3.GetObjectOutput) {
	req := &s3.GetObjectInput{
		Bucket: b.Name,
		Key:    aws.String(key),
	}

	for _, f := range opts {
		f(req)
	}

	return b.S3.GetObjectRequest(req)
}
1214506
func GetUser(w http.ResponseWriter) (interface{}, bool) {
	usr, ok := GetResponseWriter(w, func(tst http.ResponseWriter) bool {
		_, ok := tst.(*userResponseWriter)
		return ok
	})
	if ok {
		return usr.(*userResponseWriter).user, true
	}
	return nil, false
}
122927
func getResourceHandler(scope *RequestScope, getter getterFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, req *http.Request) {
		trace := utiltrace.New("Get " + req.URL.Path)
		defer trace.LogIfLong(500 * time.Millisecond)

		namespace, name, err := scope.Namer.Name(req)
		if err != nil {
			scope.err(err, w, req)
			return
		}
		ctx := req.Context()
		ctx = request.WithNamespace(ctx, namespace)

		outputMediaType, _, err := negotiation.NegotiateOutputMediaType(req, scope.Serializer, scope)
		if err != nil {
			scope.err(err, w, req)
			return
		}

		result, err := getter(ctx, name, req, trace)
		if err != nil {
			scope.err(err, w, req)
			return
		}

		trace.Step("About to write a response")
		transformResponseObject(ctx, scope, trace, req, w, http.StatusOK, outputMediaType, result)
		trace.Step("Transformed response object")
	}
}
1114404
func RequestCommManager(ctx reqContext.Context) (fab.CommManager, bool) {
	commManager, ok := ctx.Value(reqContextCommManager).(fab.CommManager)
	return commManager, ok
}
775322
func (v *ServiceGenerator_Generate_Args) GetRequest() (o *GenerateServiceRequest) {
	if v != nil && v.Request != nil {
		return v.Request
	}

	return
}
74899
func GetRequestID(req *http.Request) string {
	return req.Header.Get(common.RequestHeaderKey)
}
1222363
func (h *shadowHandler) getRequest(r io.Reader) (host string, err error) {
	// buf size should at least have the same size with the largest possible
	// request size (when addrType is 3, domain name has at most 256 bytes)
	// 1(addrType) + 1(lenByte) + 256(max length address) + 2(port)
	buf := make([]byte, smallBufferSize)

	// read till we get possible domain length field
	if _, err = io.ReadFull(r, buf[:idType+1]); err != nil {
		return
	}

	var reqStart, reqEnd int
	addrType := buf[idType]
	switch addrType & ss.AddrMask {
	case typeIPv4:
		reqStart, reqEnd = idIP0, idIP0+lenIPv4
	case typeIPv6:
		reqStart, reqEnd = idIP0, idIP0+lenIPv6
	case typeDm:
		if _, err = io.ReadFull(r, buf[idType+1:idDmLen+1]); err != nil {
			return
		}
		reqStart, reqEnd = idDm0, idDm0+int(buf[idDmLen])+lenDmBase
	default:
		err = fmt.Errorf("addr type %d not supported", addrType&ss.AddrMask)
		return
	}

	if _, err = io.ReadFull(r, buf[reqStart:reqEnd]); err != nil {
		return
	}

	// Return string for typeIP is not most efficient, but browsers (Chrome,
	// Safari, Firefox) all seems using typeDm exclusively. So this is not a
	// big problem.
	switch addrType & ss.AddrMask {
	case typeIPv4:
		host = net.IP(buf[idIP0 : idIP0+net.IPv4len]).String()
	case typeIPv6:
		host = net.IP(buf[idIP0 : idIP0+net.IPv6len]).String()
	case typeDm:
		host = string(buf[idDm0 : idDm0+int(buf[idDmLen])])
	}
	// parse port
	port := binary.BigEndian.Uint16(buf[reqEnd-2 : reqEnd])
	host = net.JoinHostPort(host, strconv.Itoa(int(port)))
	return
}
414910
func (r Resource_Metadata) GetRouter(macAddress *string) (resp string, err error) {
	params := []interface{}{
		macAddress,
	}
	err = r.Session.DoRequest("SoftLayer_Resource_Metadata", "getRouter", params, &r.Options, &resp)
	return
}
709247
func (c *Context) RequestHeader(key string) string {
	return c.Request.Header.Get(key)
}
1012552
func (cons *HTTP) requestHandler(resp http.ResponseWriter, req *http.Request) {
	if cons.htpasswd != "" {
		if !cons.checkAuth(req) {
			resp.WriteHeader(http.StatusUnauthorized)
			return
		}
	}

	if cons.withHeaders {
		// Read the whole package
		requestBuffer := bytes.NewBuffer(nil)
		if err := req.Write(requestBuffer); err != nil {
			resp.WriteHeader(http.StatusBadRequest)
			cons.Logger.Error(err)
			return // ### return, missing body or bad write ###
		}

		cons.Enqueue(requestBuffer.Bytes())
		resp.WriteHeader(http.StatusOK)
	} else {
		// Read only the message body
		if req.Body == nil {
			resp.WriteHeader(http.StatusBadRequest)
			return // ### return, missing body ###
		}

		body, err := ioutil.ReadAll(req.Body)
		if err != nil {
			resp.WriteHeader(http.StatusBadRequest)
			cons.Logger.Error(err)
			return // ### return, missing body or bad write ###
		}
		defer req.Body.Close()

		cons.Enqueue(body)
		resp.WriteHeader(http.StatusOK)
	}
}
533933
func (v *Plugin_Handshake_Args) GetRequest() (o *HandshakeRequest) {
	if v != nil && v.Request != nil {
		return v.Request
	}

	return
}
456124
func NewRequestServer(rwc io.ReadWriteCloser, h Handlers) *RequestServer {
	svrConn := &serverConn{
		conn: conn{
			Reader:      rwc,
			WriteCloser: rwc,
		},
	}
	return &RequestServer{
		serverConn:   svrConn,
		Handlers:     h,
		pktMgr:       newPktMgr(svrConn),
		openRequests: make(map[string]*Request),
	}
}
1224879
func (n *NSQRequesterFactory) GetRequester(num uint64) bench.Requester {
	return &nsqRequester{
		url:         n.URL,
		payloadSize: n.PayloadSize,
		topic:       n.Topic + "-" + strconv.FormatUint(num, 10),
		channel:     n.Topic + "-" + strconv.FormatUint(num, 10),
	}
}
104200
func (p *Provider) GetQueryExecutorForLedger(cid string) (ledger.QueryExecutor, error) {
	l := p.Peer.GetLedger(cid)
	if l == nil {
		return nil, fmt.Errorf("Could not retrieve ledger for channel %s", cid)
	}

	return l.NewQueryExecutor()
}
836423
func (q *InMemoryQueueStorage) GetRequest() ([]byte, error) {
	q.lock.Lock()
	defer q.lock.Unlock()
	if q.size == 0 {
		return nil, nil
	}
	r := q.first.Request
	q.first = q.first.Next
	q.size--
	return r, nil
}