// Helper function to retrieve a specific ResponseWriter.
431519
func GetResponseWriter(w http.ResponseWriter,
	predicate func(http.ResponseWriter) bool) (http.ResponseWriter, bool) {

	for {
		// Check if this writer is the one we're looking for
		if w != nil && predicate(w) {
			return w, true
		}
		// If it is a WrapWriter, move back the chain of wrapped writers
		ww, ok := w.(WrapWriter)
		if !ok {
			return nil, false
		}
		w = ww.WrappedWriter()
	}
}
1183157
func GetKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	defer r.Body.Close()
	vars := mux.Vars(r)
	return getKeyHandler(ctx, w, r, vars)
}
857078
func NewResponseWriter(w http.ResponseWriter) ResponseWriter {
	rw := responseWriter{w: w}
	return &rw
}
715064
func (d *domainClient) GetResponseBodyForInterception(ctx context.Context, args *GetResponseBodyForInterceptionArgs) (reply *GetResponseBodyForInterceptionReply, err error) {
	reply = new(GetResponseBodyForInterceptionReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Network.getResponseBodyForInterception", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Network.getResponseBodyForInterception", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Network", Op: "GetResponseBodyForInterception", Err: err}
	}
	return
}
1078798
func (c *Client) GetShardIterator(request GetShardIteratorRequest) (*GetShardIteratorResponse, error) {
	resp := &GetShardIteratorResponse{}
	err := c.kinesisReqWithResponse("GetShardIterator", request, resp)
	return resp, err
}
910635
func (c Context) GetWriter() keybase1.UserOrTeamID {
	if !c.Writer.IsNil() {
		return c.Writer
	}
	return c.Creator
}
853861
func getResponseFromJSON(ctx context.Context, r *httpRequest, v interface{}) error {
	r.addHeader("User-Agent", MailgunGoUserAgent)
	response, err := r.makeGetRequest(ctx)
	if err != nil {
		return err
	}
	if notGood(response.Code, expected) {
		return newError(r.URL, expected, response)
	}
	return response.parseFromJSON(v)
}
250252
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter {
	newRw := responseWriter{rw, 0, 0, nil}
	if cn, ok := rw.(http.CloseNotifier); ok {
		return &closeNotifyResponseWriter{newRw, cn}
	}
	return &newRw
}
1337397
func (remote *RemoteDebugger) GetResponseBody(req string) ([]byte, error) {
	res, err := remote.SendRequest("Network.getResponseBody", Params{
		"requestId": req,
	})

	if err != nil {
		return nil, err
	}

	body := res["body"]
	if body == nil {
		return nil, nil
	}

	if b, ok := res["base64Encoded"]; ok && b.(bool) {
		return base64.StdEncoding.DecodeString(body.(string))
	} else {
		return []byte(body.(string)), nil
	}
}
432826
func (b *Bucket) GetResponse(ctx context.Context, path string) (resp *http.Response, err error) {
	return b.GetResponseWithHeaders(ctx, path, make(http.Header))
}
886900
func GetResponse(resBytes []byte) (*peer.Response, error) {
	response := &peer.Response{}
	err := proto.Unmarshal(resBytes, response)
	return response, errors.Wrap(err, "error unmarshaling Response")
}
106402
func (c *GoContext) GetResponse() ServerResponse {
	if c.WebSocket != nil {
		return c.WebSocket
	}
	return c.Response
}
566825
func GetBoolResponse(question string, defaultAnswer bool, reader *os.File, logger *logging.Logger) (bool, error) {
	var result bool
	readr := bufio.NewReader(reader)
	logger.InfoMsg(question)

	text, _ := readr.ReadString('\n')
	text = strings.Replace(text, "\n", "", 1)
	if text == "" {
		return defaultAnswer, nil
	}

	if text == "Yes" || text == "YES" || text == "Y" || text == "y" {
		result = true
	} else {
		result = false
	}

	return result, nil
}
879502
func (c *Client) GetResponseJson(method string, requestUrl string, requestPath string, body string) (responseBody string, err error) {

	//	fmt.Println("method %s, requestPath: %s", requestUrl, requestPath)
	reqest, err := http.NewRequest(method, requestUrl, strings.NewReader(body))
	if err != nil {
		return responseBody, err
	}

	InitBaseHeader(reqest)

	//	如果是post请求，并且有post请求内容则加上Content-MD5头
	if body != "" && method == "POST" {
		reqest.Header.Set("Content-MD5", BodyMd5(body))
	}

	if c.securityToken != "" {
		reqest.Header["x-acs-security-token"] = []string{c.securityToken}
	}

	c.Sign(method, requestPath, reqest, "")

	if method != "POST" {
		reqest.Header.Del("Content-MD5")

	}
	//reqest.Header.Del("Accept-Encoding")
	reqest.Header.Set("Accept-Encoding", "deflate,sdch")

	log.Printf("RequestUrl = %++v", reqest)
	client := &http.Client{}
	t0 := time.Now()
	response, err := client.Do(reqest)
	t1 := time.Now()
	if err != nil {
		return body, err
	}

	if c.debug {
		log.Printf("Invoke %s %s %d (%v)", method, requestUrl, response.StatusCode, t1.Sub(t0))
	}

	rsBody, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return "", err
	}
	//如果状态吗是非200则进行返回值的过滤,使得pop返回的错误和程序的错误输出一致
	if response.StatusCode != 200 {
		err = errors.New("Response status code faild" + string(rsBody))
		type ResultError struct {
			RequestId string `json:"requestId"`
			HostId    string `json:"hostId"`
			Code      string `json:"code"`
			Message   string `json:"Message"`
		}
		var rsError ResultError
		rsBodyString := string(rsBody)
		_ = json.Unmarshal([]byte(rsBodyString), &rsError)

		newResult := ResultModel{
			rsError.Code,
			rsError.Message,
			false,
		}

		resultJson, _ := json.Marshal(newResult)

		return string(resultJson), err

	}

	return string(rsBody), err
}
1163546
func (api UsersAPI) Get(w http.ResponseWriter, r *http.Request) {
	respBody := User{Name: "John", Username: "Doe"}
	json.NewEncoder(w).Encode(&respBody)
	// uncomment below line to add header
	// w.Header().Set("key","value")
}
1366231
func (d *Doer) Get(url string, response interface{}) (*http.Response, error) {
	req, err := d.newRequest(http.MethodGet, url, nil)
	if err != nil {
		return nil, err
	}

	return d.do(req, response)
}
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
}