// newResponse creates a new Response for testing purposes
967815
func newResponse(w http.ResponseWriter, context Context) *Response {
	return &Response{ResponseWriter: w, context: context}
}
1326198
func newQueryResponse(n int, q *messageQuery) *QueryResponse {
	resp := &QueryResponse{
		deadline:  time.Now().Add(q.Timeout),
		id:        q.ID,
		lTime:     q.LTime,
		respCh:    make(chan NodeResponse, n),
		responses: make(map[string]struct{}),
	}
	if q.Ack() {
		resp.ackCh = make(chan string, n)
		resp.acks = make(map[string]struct{})
	}
	return resp
}
169457
func (o *CreateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {

	case 201:
		result := NewCreateCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil

	default:
		result := NewCreateDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}
917167
func NewResponder(source Source, stats Stats) *Responder {
	return &Responder{
		Source: source,
		stats:  stats,
		clk:    clock.New(),
	}
}
735008
func JSONResponse(w http.ResponseWriter, v interface{}) error {
	w.Header().Set(HeaderContentType, JSONType)
	return json.NewEncoder(w).Encode(v)
}
370158
func newResponse(r *http.Response) *Response {
	response := &Response{Response: r}
	response.populatePageValues()
	response.Rate = parseRate(r)
	return response
}
380171
func NewUploadPackResponse(req *UploadPackRequest) *UploadPackResponse {
	isShallow := !req.Depth.IsZero()
	isMultiACK := req.Capabilities.Supports(capability.MultiACK) ||
		req.Capabilities.Supports(capability.MultiACKDetailed)

	return &UploadPackResponse{
		isShallow:  isShallow,
		isMultiACK: isMultiACK,
	}
}
775658
func NewResponse(w ServerResponse) (r *Response) {
	r = &Response{Out: OutResponse{Server: w, internalHeader: &RevelHeader{}}}
	r.Out.response = r
	return r
}
1013248
func (o *UploadTaskFileReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {

	case 201:
		result := NewUploadTaskFileCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil

	default:
		result := NewUploadTaskFileDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}
420720
func (o *PostNodesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {

	case 201:
		result := NewPostNodesCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil

	default:
		result := NewPostNodesDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	}
}
769844
func NewBytesResponse(status int, body []byte) *http.Response {
	return &http.Response{
		Status:        strconv.Itoa(status),
		StatusCode:    status,
		Body:          NewRespBodyFromBytes(body),
		Header:        http.Header{},
		ContentLength: -1,
	}
}
89169
func NewRequest(url string, options ...Option) (*http.Response, error) {
	request, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}

	request.Header.Add("Accept", "application/json")
	request.Header.Add("User-Agent", "Performance-Platform-Client/1.0")

	requestOptions := RequestOptions{MaxElapsedTime: 5 * time.Second}
	requestOptions.option(request, options...)

	response, err := tryGet(request, requestOptions)

	if err != nil {
		return nil, err
	}

	if response.StatusCode == http.StatusNotFound {
		return nil, ErrNotFound
	}

	if response.StatusCode == http.StatusBadRequest {
		return response, ErrBadRequest
	}

	return response, err
}
1183752
func NewResponseFromMessage(robot *Robot, msg *Message) *Response {
	return &Response{
		Robot: robot,
		Envelope: &Envelope{
			Room: msg.Room,
			User: &msg.User,
		},
		Message: msg,
	}
}
106587
func NewErrorResponder(err error) Responder {
	return func(req *http.Request) (*http.Response, error) {
		return nil, err
	}
}
1081257
func newResponse(data *textproto.MIMEHeader) (*AMIResponse, error) {
	if data.Get("Response") == "" {
		return nil, errors.New("Not Response")
	}
	
	response := &AMIResponse{data.Get("Actionid"),
		data.Get("Response"),
		make(map[string]string)}

	for k, v := range *data {
		if k == "Response" {
			continue
		}
		response.Params[k] = v[0]
	}
	return response, nil
}
1030195
func SendResponse(w io.Writer, data []byte) (int, error) {
	err := binary.Write(w, binary.BigEndian, int32(len(data)))
	if err != nil {
		return 0, err
	}

	n, err := w.Write(data)
	if err != nil {
		return 0, err
	}

	return (n + 4), nil
}
849022
func ResponderFromResponse(resp *http.Response) Responder {
	return func(req *http.Request) (*http.Response, error) {
		res := new(http.Response)
		*res = *resp
		res.Request = req
		return res, nil
	}
}