// Status succeeds if response contains given status code.
//
// Example:
//  resp := NewResponse(t, response)
//  resp.Status(http.StatusOK)
356870
func (r *Response) Status(status int) *Response {
	if r.chain.failed() {
		return r
	}
	r.checkEqual("status", statusCodeText(status), statusCodeText(r.resp.StatusCode))
	return r
}
753707
func CheckResponse(response *APIResponse) (err error) {
	if response.HTTP.StatusCode < 200 || response.HTTP.StatusCode >= 400 {

		errorParts := []string{
			fmt.Sprintf("Received HTTP Status '%s'", response.HTTP.Status),
		}
		if message := createErrorResponseMessage(response.Body); message != "" {
			errorParts = append(errorParts, message)
		}

		err = errors.New(strings.Join(errorParts, ": "))
	}
	return
}
135443
func (r *Repo) Status() (GitRepoStatus, error) {
	r.mu.RLock()
	defer r.mu.RUnlock()
	return r.status, r.err
}
729253
func (hc *Check) Status() Status {
	hc.lock.RLock()
	defer hc.lock.RUnlock()
	status := Status{
		LastCheck: hc.start,
		Failures:  hc.failures,
		Successes: hc.successes,
		State:     hc.state,
	}
	if hc.result != nil {
		status.Duration = hc.result.Duration
		status.Message = hc.result.String()
	}
	return status
}
1329965
func (i *environInstance) Status(ctx context.ProviderCallContext) instance.Status {
	jujuStatus := status.Pending
	code := i.container.StatusCode
	switch code {
	case api.Starting, api.Started:
		jujuStatus = status.Allocating
	case api.Running:
		jujuStatus = status.Running
	case api.Freezing, api.Frozen, api.Thawed, api.Stopping, api.Stopped:
		jujuStatus = status.Empty
	default:
		jujuStatus = status.Empty
	}
	return instance.Status{
		Status:  jujuStatus,
		Message: code.String(),
	}

}
262426
func (r *httpVPackResponseElement) StatusCode() int {
	if r.statusCode == nil {
		statusCode := 200
		// Look for "error" field
		if errorFieldSlice, _ := r.slice.Get("error"); !errorFieldSlice.IsNone() {
			if hasError, err := errorFieldSlice.GetBool(); err == nil && hasError {
				// We have an error, look for code field
				statusCode = 500
				if codeFieldSlice, _ := r.slice.Get("code"); !codeFieldSlice.IsNone() {
					if code, err := codeFieldSlice.GetInt(); err == nil {
						statusCode = int(code)
					}
				}
			}
		}
		r.statusCode = &statusCode
	}
	return *r.statusCode
}
1027950
func (wc *WebhookContext) Response(code int, s string) {
	wc.gin.String(code, s)
}
805438
func CodeStatus(code codes.Code) int {
	if status, ok := codeToStatus[code]; ok {
		return status
	}
	return http.StatusInternalServerError
}
996416
func StatusCode(err error) int {
	if err == nil {
		return http.StatusOK
	}
	if val, ok := errors.TagValueIn(statusCodeTagKey, err); ok {
		return val.(int)
	}
	return 0
}
1360739
func ReplyWithStatus(res *http.Response, code int) {
	res.StatusCode = code
	res.Status = strconv.Itoa(code) + " " + http.StatusText(code)
}
1269701
func (s *SQL) Status() (interface{}, error) {
	if err := validateSQLConfig(s.Config); err != nil {
		return nil, err
	}

	switch {
	// check for SQLExecer first
	case s.Config.Execer != nil:
		// if the result handler is nil, use the default
		if s.Config.ExecerResultHandler == nil {
			s.Config.ExecerResultHandler = DefaultExecHandler
		}
		// run the execer
		return s.runExecer()
	// check for SQLQueryer next
	case s.Config.Queryer != nil:
		// if the result handler is nil, use the default
		if s.Config.QueryerResultHandler == nil {
			s.Config.QueryerResultHandler = DefaultQueryHandler
		}
		// run the queryer
		return s.runQueryer()
	// finally, must be a pinger
	default:
		ctx := context.Background()
		return nil, s.Config.Pinger.PingContext(ctx)
	}
}
411553
func (s *StatusGetter) Status(args params.Entities) (params.StatusResults, error) {
	result := params.StatusResults{
		Results: make([]params.StatusResult, len(args.Entities)),
	}
	canAccess, err := s.getCanAccess()
	if err != nil {
		return params.StatusResults{}, err
	}
	for i, entity := range args.Entities {
		tag, err := names.ParseTag(entity.Tag)
		if err != nil {
			result.Results[i].Error = ServerError(err)
			continue
		}
		if !canAccess(tag) {
			result.Results[i].Error = ServerError(ErrPerm)
			continue
		}
		result.Results[i] = s.getEntityStatus(tag)
	}
	return result, nil
}
18856
func jsonStatusResponse(w http.ResponseWriter, code int) {
	w.Header().Set("Content-Type", jsonContentType)
	w.WriteHeader(code)
	err := json.NewEncoder(w).Encode(StatusResponse{
		Message: http.StatusText(code),
		Code:    code,
	})
	if err != nil {
		log.Error("chunk explorer: json status response", "err", err)
	}
}
22504
func (this *statusResponseWriter) Write(data []byte) (int, error) {
	if this.code == 0 {
		this.code = http.StatusOK
	}
	return this.ResponseWriter.Write(data)
}
219621
func (r *successResponse) check(err error) (statusCode int) {
	if err == nil {
		r.Success = true
		return 0
	}

	cause := errors.Cause(err)

	// Determine HTTP status code based on the error type.
	switch cause.(type) {
	case pilosa.BadRequestError:
		statusCode = http.StatusBadRequest
	case pilosa.ConflictError:
		statusCode = http.StatusConflict
	case pilosa.NotFoundError:
		statusCode = http.StatusNotFound
	default:
		statusCode = http.StatusInternalServerError
	}

	r.Success = false
	r.Error = &Error{Message: err.Error()}

	return statusCode
}
994841
func (h *HTTP) Status() (interface{}, error) {
	resp, err := h.do()
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	// Check if StatusCode matches
	if resp.StatusCode != h.Config.StatusCode {
		return nil, fmt.Errorf("Received status code '%v' does not match expected status code '%v'",
			resp.StatusCode, h.Config.StatusCode)
	}

	// If Expect is set, verify if returned response contains expected data
	if h.Config.Expect != "" {
		data, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return nil, fmt.Errorf("Unable to read response body to perform content expectancy check: %v", err)
		}

		if !strings.Contains(string(data), h.Config.Expect) {
			return nil, fmt.Errorf("Received response body '%v' does not contain expected content '%v'",
				string(data), h.Config.Expect)
		}
	}

	return nil, nil
}
1018612
func (r *httpJSONResponseElement) StatusCode() int {
	if r.statusCode == nil {
		statusCode := 200
		// Look for "error" field
		if errorFieldJSON, found := r.bodyObject["error"]; found {
			var hasError bool
			if err := json.Unmarshal(*errorFieldJSON, &hasError); err == nil && hasError {
				// We have an error, look for code field
				statusCode = 500
				if codeFieldJSON, found := r.bodyObject["code"]; found {
					var code int
					if err := json.Unmarshal(*codeFieldJSON, &code); err == nil {
						statusCode = code
					}
				}
			}
		}
		r.statusCode = &statusCode
	}
	return *r.statusCode
}