// OKTiny sends a HTTP response with status code 200.
340818
func (ctx *ListBottleContext) OKTiny(r BottleTinyCollection) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.bottle+json; type=collection")
	}
	if r == nil {
		r = BottleTinyCollection{}
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
768480
func (r *Response) Status(code int) JResponseWriter {
	r.code = code
	return r
}
407434
func (rc *ReadinessCheck) SetHTTPStatusCodesForReady(codes []int) *ReadinessCheck {
	rc.HTTPStatusCodesForReady = &codes
	return rc
}
232270
func (ctx *ListAccountContext) OK(r AccountCollection) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json; type=collection")
	}
	if r == nil {
		r = AccountCollection{}
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
1314559
func (rm *responseModifier) WriteHeader(s int) {

	// Use original request if hijacked
	if rm.hijacked {
		rm.rw.WriteHeader(s)
		return
	}

	rm.statusCode = s
}
1093946
func (s *WebsocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	logger.Println("WebsocketServer.ServeHTTP", r.Method, r.RequestURI)
	// TODO: subprotocol?
	conn, err := s.Upgrader.Upgrade(w, r, nil)
	if err != nil {
		logger.Println("Error upgrading to websocket connection:", err)
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	s.handleWebsocket(conn)
}
1159450
func (h *handshake) postY(x *big.Int) error {
	var y big.Int
	y.Exp(&g, x, &p)
	return h.postWrite(paddedLeft(y.Bytes(), 96))
}
633762
func (w *ResponseWriter) WriteHeader(status int) {
	if w.wroteHeader {
		return
	}

	if w.Header().Get("Content-Type") == "" {
		w.Header().Set("Content-Type", "text/plain; charset=utf8")
	}

	w.out.StatusCode = status

	h := make(map[string]string)

	for k, v := range w.Header() {
		if len(v) > 0 {
			h[k] = v[len(v)-1]
		}
	}

	w.out.Headers = h
	w.wroteHeader = true
}
594833
func (service *HTTPService) ServeHTTP(
	response http.ResponseWriter, request *http.Request) {
	if service.clientAccessPolicyXMLHandler(response, request) ||
		service.crossDomainXMLHandler(response, request) {
		return
	}
	context := service.acquireContext()
	context.InitHTTPContext(service, response, request)
	var resp []byte
	err := service.sendHeader(context)
	if err == nil {
		switch request.Method {
		case "GET":
			if service.GET {
				resp = service.DoFunctionList(context)
			} else {
				response.WriteHeader(403)
			}
		case "POST":
			var req []byte
			if req, err = readAllFromHTTPRequest(request); err == nil {
				resp = service.Handle(req, context)
			}
		}
	}
	if err != nil {
		resp = service.EndError(err, context)
	}
	service.releaseContext(context)
	response.Header().Set("Content-Length", util.Itoa(len(resp)))
	response.Write(resp)
}
844230
func (r *Response) StatusCode() int {
	if r.RawResponse == nil {
		return 0
	}

	return r.RawResponse.StatusCode
}
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)
	}
}
707715
func (s *rpcServer) writeHTTPResponseHeaders(req *http.Request, headers http.Header, code int, w io.Writer) error {
	_, err := io.WriteString(w, s.httpStatusLine(req, code))
	if err != nil {
		return err
	}

	err = headers.Write(w)
	if err != nil {
		return err
	}

	_, err = io.WriteString(w, "\r\n")
	return err
}
337824
func MarkIdle(c net.Conn) error {
	if cn, ok := c.(*conn); ok {
		cn.markIdle()
		return nil
	}
	return errNotManaged
}
23042
func (req *SrvReq) RespondRwstat() {
	err := PackRwstat(req.Rc)
	if err != nil {
		req.RespondError(err)
	} else {
		req.Respond()
	}
}
1223034
func Orthodox() {
	DefaultMux.Middleware(ResponseMapper())
	DefaultMux.Middleware(HTTPRWDI())
	DefaultMux.Middleware(ContextDI())
	DefaultMux.Middleware(RequestObjectMapper())
}
599744
func R201(w http.ResponseWriter, data interface{}) {
	SendResponse(w, data, http.StatusCreated)
}
1141457
func (service *WebSocketService) ServeHTTP(
	response http.ResponseWriter, request *http.Request) {
	if request.Method == "GET" && !strings.Contains(strings.ToLower(request.Header.Get("connection")), "upgrade") || request.Method == "POST" || request.Method == "OPTIONS" {
		service.HTTPService.ServeHTTP(response, request)
		return
	}
	conn, err := service.Upgrade(response, request, nil)
	if err != nil {
		context := new(rpc.HTTPContext)
		context.InitHTTPContext(service, response, request)
		resp := service.EndError(err, context)
		response.Header().Set("Content-Length", util.Itoa(len(resp)))
		response.Write(resp)
		return
	}
	defer conn.Close()

	mutex := new(sync.Mutex)
	for {
		msgType, data, err := conn.ReadMessage()
		if err != nil {
			break
		}
		if msgType == websocket.BinaryMessage {
			go service.handle(data, mutex, response, request, conn)
		}
	}
}