// Unmarshal unmarshals the REST component of a response in a REST service. func Unmarshal(r *aws.Request) { if r.DataFilled() { v := reflect.Indirect(reflect.ValueOf(r.Data)) unmarshalBody(r, v) unmarshalLocationElements(r, v) } }
// Unmarshal unmarshals a response for a JSON RPC service. func Unmarshal(req *aws.Request) { defer req.HTTPResponse.Body.Close() if req.DataFilled() { err := jsonutil.UnmarshalJSON(req.Data, req.HTTPResponse.Body) if err != nil { req.Error = awserr.New("SerializationError", "failed decoding JSON RPC response", err) } } return }
func verifySendMessage(r *aws.Request) { if r.DataFilled() && r.ParamsFilled() { in := r.Params.(*SendMessageInput) out := r.Data.(*SendMessageOutput) err := checksumsMatch(in.MessageBody, out.MD5OfMessageBody) if err != nil { setChecksumError(r, err.Error()) } } }
// Unmarshal unmarshals a response body for the EC2 protocol. func Unmarshal(r *aws.Request) { defer r.HTTPResponse.Body.Close() if r.DataFilled() { decoder := xml.NewDecoder(r.HTTPResponse.Body) err := xmlutil.UnmarshalXML(r.Data, decoder, "") if err != nil { r.Error = awserr.New("SerializationError", "failed decoding EC2 Query response", err) return } } }
func verifyReceiveMessage(r *aws.Request) { if r.DataFilled() && r.ParamsFilled() { ids := []string{} out := r.Data.(*ReceiveMessageOutput) for _, msg := range out.Messages { err := checksumsMatch(msg.Body, msg.MD5OfBody) if err != nil { ids = append(ids, *msg.MessageID) } } if len(ids) > 0 { setChecksumError(r, "invalid messages: %s", strings.Join(ids, ", ")) } } }
func buildGetBucketLocation(r *aws.Request) { if r.DataFilled() { out := r.Data.(*GetBucketLocationOutput) b, err := ioutil.ReadAll(r.HTTPResponse.Body) if err != nil { r.Error = awserr.New("SerializationError", "failed reading response body", err) return } match := reBucketLocation.FindSubmatch(b) if len(match) > 1 { loc := string(match[1]) out.LocationConstraint = &loc } } }
func verifySendMessageBatch(r *aws.Request) { if r.DataFilled() && r.ParamsFilled() { entries := map[string]*SendMessageBatchResultEntry{} ids := []string{} out := r.Data.(*SendMessageBatchOutput) for _, entry := range out.Successful { entries[*entry.ID] = entry } in := r.Params.(*SendMessageBatchInput) for _, entry := range in.Entries { if e := entries[*entry.ID]; e != nil { err := checksumsMatch(entry.MessageBody, e.MD5OfMessageBody) if err != nil { ids = append(ids, *e.MessageID) } } } if len(ids) > 0 { setChecksumError(r, "invalid messages: %s", strings.Join(ids, ", ")) } } }