Skip to content

Instantly share code, notes, and snippets.

@blaines
Created May 11, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaines/2433c3cfc22e1290609f7847e8c5cf00 to your computer and use it in GitHub Desktop.
Save blaines/2433c3cfc22e1290609f7847e8c5cf00 to your computer and use it in GitHub Desktop.
diff --git a/private/protocol/restxml/restxml.go b/private/protocol/restxml/restxml.go
index 65faeae..27e0e86 100644
--- a/private/protocol/restxml/restxml.go
+++ b/private/protocol/restxml/restxml.go
@@ -8,7 +8,10 @@ package restxml
import (
"bytes"
"encoding/xml"
+ "fmt"
"io"
+ "strings"
+ "unicode"
request "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/awserr"
@@ -66,12 +69,29 @@ func Build(r *request.Request) {
// Unmarshal unmarshals a payload response for the REST XML protocol.
func Unmarshal(r *request.Request) {
+ fmt.Println("HELLO UNMARSHAL", rest.PayloadType(r.Data))
if t := rest.PayloadType(r.Data); t == "structure" || t == "" {
defer r.HTTPResponse.Body.Close()
- decoder := xml.NewDecoder(r.HTTPResponse.Body)
+ buf := new(bytes.Buffer)
+ buf.ReadFrom(r.HTTPResponse.Body)
+ printOnly := func(r rune) rune {
+ if unicode.IsPrint(r) {
+ return r
+ }
+ return -1
+ }
+ xmlData := []byte(strings.Map(printOnly, string(buf.Bytes())))
+
+ // fmt.Println("DATA", r.Data)
+
+ // newStr := buf.String()
+ // fmt.Printf("HEXDUMP\n%x\n", buf.Bytes())
+ // fmt.Println("XMLDATA:", buf.Bytes())
+ decoder := xml.NewDecoder(bytes.NewReader(xmlData))
err := xmlutil.UnmarshalXML(r.Data, decoder, "")
if err != nil {
- r.Error = awserr.New("SerializationError", "failed to decode REST XML response", err)
+ fmt.Println("ERROR", err)
+ r.Error = awserr.New("SerializationError", "failed to decode REST XML response 11111111111", err)
return
}
} else {
(END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment