// Respond replies to the request with the given response,
// giving the updated attributes.
165695
func (r *SetattrRequest) Respond(resp *SetattrResponse) {
	out := &attrOut{
		outHeader:     outHeader{Unique: uint64(r.ID)},
		AttrValid:     uint64(resp.AttrValid / time.Second),
		AttrValidNsec: uint32(resp.AttrValid % time.Second / time.Nanosecond),
		Attr:          resp.Attr.attr(),
	}
	r.Conn.respond(&out.outHeader, unsafe.Sizeof(*out))
}
128352
func Reply(w http.ResponseWriter, response interface{}, status int) {
	// marshal the body of the response
	marshalledResponse, err := json.Marshal(response)
	if err != nil {
		marshalledResponse = []byte(fmt.Sprintf(`{"message": "Failed to marshal response: %v %v"}`, response, err))
		status = http.StatusInternalServerError
		LogRequest(nil, status, time.Nanosecond, err)
	}

	// write JSON response
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	w.WriteHeader(status)
	w.Write(marshalledResponse)
}
550891
func (sm *storeManager) respond() {
	for w, req := range sm.waiting {
		revno := w.revno
		changes := sm.all.ChangesSince(revno)
		if len(changes) == 0 {
			if req.noChanges != nil {
				req.noChanges <- struct{}{}
				sm.removeWaitingReq(w, req)
			}
			continue
		}

		req.changes = changes
		w.revno = sm.all.latestRevno
		select {
		case req.reply <- true:
		case <-sm.tomb.Dying():
		}
		sm.removeWaitingReq(w, req)
		sm.seen(revno)
	}
}
1219027
func (auth *v1Auth) Response(resp *http.Response) error {
	auth.Headers = resp.Header
	return nil
}
632864
func (r *GetxattrRequest) Respond(resp *GetxattrResponse) {
	out := &getxattrOut{
		outHeader: outHeader{Unique: uint64(r.ID)},
		Size:      uint32(len(resp.Xattr)),
	}
	r.Conn.respondData(&out.outHeader, unsafe.Sizeof(*out), resp.Xattr)
}
191538
func (r *Request) Reply(ok bool, payload []byte) error {
	if !r.WantReply {
		return nil
	}

	if r.ch == nil {
		return r.mux.ackRequest(ok, payload)
	}

	return r.ch.ackRequest(ok)
}
404296
func (t *SimpleChaincode) respond(stub shim.ChaincodeStubInterface, args []string) pb.Response {
	if len(args) != 3 {
		return shim.Error("expected three arguments")
	}

	status, err := strconv.ParseInt(args[0], 10, 32)
	if err != nil {
		return shim.Error(err.Error())
	}
	message := args[1]
	payload := []byte(args[2])

	return pb.Response{
		Status:  int32(status),
		Message: message,
		Payload: payload,
	}
}
975339
func (r *ChainResponse) Send(response *restful.Response) {
	var keys []string
	for k := range r.chains {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	for _, k := range keys {
		r.Chains = append(r.Chains, prepareChainResponse(r.Context, r.chains[k]))
	}

	r.Response.Send(response)
}
510717
func (packet *packetMock) Respond(msg *proto.GossipMessage) {
	sMsg, _ := msg.NoopSign()
	packet.src.socket <- &packetMock{
		src: packet.dst,
		dst: packet.src,
		msg: sMsg,
	}
}
67442
func (fn UpdateTaskHandlerFunc) Handle(params UpdateTaskParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
1370432
func (r *Request) Send() error {
	// Always run Complete handlers
	defer func() {
		r.Handlers.Complete.Run(r)
	}()

	// Build and Sign the request.
	r.Build()
	if r.Error != nil {
		return r.Error
	}

	// Send the request. r.HTTPResponse should be populated after these handlers run.
	r.Handlers.Send.Run(r)
	if r.Error != nil {
		return r.Error
	}

	// Validate the response. This is a good place to create a r.Error if
	// the response is not a 2xx status code.
	r.Handlers.ValidateResponse.Run(r)
	if r.Error != nil {
		// Run DecodeError handlers. This is a good place to add custom error response
		// parsing.
		r.Handlers.DecodeError.Run(r)
		return r.Error
	}

	// Decode the response. Commonly will populate r.Data variable with a parsed response body.
	r.Handlers.Decode.Run(r)
	return r.Error
}
317645
func (e *Entry) Response() (*Response, bool) {
	if !e.valid() {
		// it has been expired
		return nil, false
	}
	return e.response, true
}
1327752
func (r Response) Apply() error {
	var req, opts, err = r.applyRequest()

	if err != nil {
		return err
	}

	return r.applyUpdate(req, opts)
}
77250
func (c *RPCClient) Respond(id uint64, buf []byte) error {
	header := requestHeader{
		Command: respondCommand,
		Seq:     c.getSeq(),
	}
	req := respondRequest{
		ID:      id,
		Payload: buf,
	}
	return c.genericRPC(&header, &req, nil)
}
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))
}
41263
func (auth *v2Auth) Response(resp *http.Response) error {
	auth.Auth = new(v2AuthResponse)
	err := readJson(resp, auth.Auth)
	// If successfully read Auth then no need to toggle useApiKey any more
	if err == nil {
		auth.useApiKeyOk = true
	}
	return err
}
324492
func (o OAuthSession) Reply(r Replier, comment string) (*Comment, error) {
	// Build form for POST request.
	form := url.Values{
		"api_type": {"json"},
		"thing_id": {r.replyID()},
		"text":     {comment},
	}

	type response struct {
		JSON struct {
			Errors [][]string
			Data   struct {
				Things []struct {
					Data map[string]interface{}
				}
			}
		}
	}

	res := &response{}

	err := o.postBody("https://oauth.reddit.com/api/comment", form, res)
	if err != nil {
		return nil, err
	}

	if len(res.JSON.Errors) != 0 {
		var msg []string
		for _, k := range res.JSON.Errors {
			msg = append(msg, k[1])
		}
		return nil, errors.New(strings.Join(msg, ", "))
	}

	c := makeComment(res.JSON.Data.Things[0].Data)

	return c, nil
}