// WriteResponse to the client.
197086
func (a *APIError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
	rw.WriteHeader(a.code)
	m := a.GetModel()
	if err := producer.Produce(rw, m); err != nil {
		panic(err)
	}

}
128207
func (ccr corsCodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}, methodErr error) error {
	if len(ccr.corsDomains) > 0 {
		w.Header().Add("Access-Control-Allow-Origin", strings.Join(ccr.corsDomains, " "))
	}
	return ccr.baseCodecRequest.WriteResponse(w, reply, methodErr)
}
1097145
func EncodeResponse(cached *CachedResponse, writer io.Writer) error {
	return gob.NewEncoder(writer).Encode(cached)
}
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()
	}
}
1250370
func WriteTextResponse(w http.ResponseWriter, status int, body string) {
	w.Header().Set("Content-Type", "text/plain; charset=utf-8")
	w.Header().Set("X-Content-Type-Options", "nosniff")
	w.WriteHeader(status)
	w.Write([]byte(body))
}
91385
func (resp *Response) WriteHeader(defaultStatusCode int, defaultContentType string) {
	if resp.ContentType == "" {
		resp.ContentType = defaultContentType
	}
	resp.Out.internalHeader.Set("Content-Type", resp.ContentType)
	if resp.Status == 0 {
		resp.Status = defaultStatusCode
	}
	resp.SetStatus(resp.Status)
}
227795
func (r *ResponseRecorder) WriteHeader(status int) {
	r.status = status
	r.ResponseWriterWrapper.WriteHeader(status)
}
935142
func (o *InventoryGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

	rw.WriteHeader(200)
	payload := o.Payload
	if payload == nil {
		// return empty map
		payload = make(map[string]int32, 50)
	}

	if err := producer.Produce(rw, payload); err != nil {
		panic(err) // let the recovery middleware deal with this
	}
}
1040928
func SendResponseWithClient(client interface {
	Do(*http.Request) (*http.Response, error)
}, req Request, response Response) error {
	c := ResponseClient{client}
	return c.SendResponse(req, response)
}
990282
func (r *WriteRequest) Respond(resp *WriteResponse) {
	out := &writeOut{
		outHeader: outHeader{Unique: uint64(r.ID)},
		Size:      uint32(resp.Size),
	}
	r.Conn.respond(&out.outHeader, unsafe.Sizeof(*out))
}
37314
func (o *GetEndpointIDLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

	rw.WriteHeader(200)
	payload := o.Payload
	if payload == nil {
		// return empty array
		payload = models.EndpointStatusLog{}
	}

	if err := producer.Produce(rw, payload); err != nil {
		panic(err) // let the recovery middleware deal with this
	}
}
1028875
func SendResponse(w http.ResponseWriter, data interface{}, rCode int) {
	rw := responseWriter{
		ResponseWriter: w,
		code:           rCode,
	}

	err := json.NewEncoder(rw).Encode(dOutput{Data: data, Status: rCode})
	if err != nil {
		/*
			In case of encoding error, send "internal server error" after
			logging the actual error.
		*/
		LOGHANDLER.Error(err)
		R500(w, ErrInternalServer)
	}
}
391370
func writeErrorResponseJSON(ctx context.Context, w http.ResponseWriter, err APIError, reqURL *url.URL) {
	// Generate error response.
	errorResponse := getAPIErrorResponse(ctx, err, reqURL.Path, w.Header().Get(responseRequestIDKey), w.Header().Get(responseDeploymentIDKey))
	encodedErrorResponse := encodeResponseJSON(errorResponse)
	writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeJSON)
}
45475
func writeErrorResponse(ctx context.Context, w http.ResponseWriter, err APIError, reqURL *url.URL, browser bool) {
	switch err.Code {
	case "SlowDown", "XMinioServerNotInitialized", "XMinioReadQuorum", "XMinioWriteQuorum":
		// Set retry-after header to indicate user-agents to retry request after 120secs.
		// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
		w.Header().Set("Retry-After", "120")
	case "AccessDenied":
		// The request is from browser and also if browser
		// is enabled we need to redirect.
		if browser {
			w.Header().Set("Location", minioReservedBucketPath+reqURL.Path)
			w.WriteHeader(http.StatusTemporaryRedirect)
			return
		}
	}

	// Generate error response.
	errorResponse := getAPIErrorResponse(ctx, err, reqURL.Path,
		w.Header().Get(responseRequestIDKey), w.Header().Get(responseDeploymentIDKey))
	encodedErrorResponse := encodeResponse(errorResponse)
	writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeXML)
}
62076
func writeSuccessResponseXML(w http.ResponseWriter, response []byte) {
	writeResponse(w, http.StatusOK, response, mimeXML)
}
857078
func NewResponseWriter(w http.ResponseWriter) ResponseWriter {
	rw := responseWriter{w: w}
	return &rw
}
189549
func (rw *responseWriter) WriteHeader(c int) {
	if rw.Written() {
		return
	}
	rw.status = c
	rw.w.WriteHeader(c)
}