aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/aws/aws-sdk-go/private/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/private/protocol')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/debug.go144
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/decode.go199
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/encode.go114
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/error.go23
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/api.go196
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/error.go24
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header.go166
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header_value.go501
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/message.go103
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/jsonvalue.go76
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/payload.go81
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go2
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go11
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go33
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go20
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go72
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go18
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go20
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go1
19 files changed, 1768 insertions, 36 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/debug.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/debug.go
new file mode 100644
index 0000000..ecc7bf8
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/debug.go
@@ -0,0 +1,144 @@
1package eventstream
2
3import (
4 "bytes"
5 "encoding/base64"
6 "encoding/json"
7 "fmt"
8 "strconv"
9)
10
11type decodedMessage struct {
12 rawMessage
13 Headers decodedHeaders `json:"headers"`
14}
15type jsonMessage struct {
16 Length json.Number `json:"total_length"`
17 HeadersLen json.Number `json:"headers_length"`
18 PreludeCRC json.Number `json:"prelude_crc"`
19 Headers decodedHeaders `json:"headers"`
20 Payload []byte `json:"payload"`
21 CRC json.Number `json:"message_crc"`
22}
23
24func (d *decodedMessage) UnmarshalJSON(b []byte) (err error) {
25 var jsonMsg jsonMessage
26 if err = json.Unmarshal(b, &jsonMsg); err != nil {
27 return err
28 }
29
30 d.Length, err = numAsUint32(jsonMsg.Length)
31 if err != nil {
32 return err
33 }
34 d.HeadersLen, err = numAsUint32(jsonMsg.HeadersLen)
35 if err != nil {
36 return err
37 }
38 d.PreludeCRC, err = numAsUint32(jsonMsg.PreludeCRC)
39 if err != nil {
40 return err
41 }
42 d.Headers = jsonMsg.Headers
43 d.Payload = jsonMsg.Payload
44 d.CRC, err = numAsUint32(jsonMsg.CRC)
45 if err != nil {
46 return err
47 }
48
49 return nil
50}
51
52func (d *decodedMessage) MarshalJSON() ([]byte, error) {
53 jsonMsg := jsonMessage{
54 Length: json.Number(strconv.Itoa(int(d.Length))),
55 HeadersLen: json.Number(strconv.Itoa(int(d.HeadersLen))),
56 PreludeCRC: json.Number(strconv.Itoa(int(d.PreludeCRC))),
57 Headers: d.Headers,
58 Payload: d.Payload,
59 CRC: json.Number(strconv.Itoa(int(d.CRC))),
60 }
61
62 return json.Marshal(jsonMsg)
63}
64
65func numAsUint32(n json.Number) (uint32, error) {
66 v, err := n.Int64()
67 if err != nil {
68 return 0, fmt.Errorf("failed to get int64 json number, %v", err)
69 }
70
71 return uint32(v), nil
72}
73
74func (d decodedMessage) Message() Message {
75 return Message{
76 Headers: Headers(d.Headers),
77 Payload: d.Payload,
78 }
79}
80
81type decodedHeaders Headers
82
83func (hs *decodedHeaders) UnmarshalJSON(b []byte) error {
84 var jsonHeaders []struct {
85 Name string `json:"name"`
86 Type valueType `json:"type"`
87 Value interface{} `json:"value"`
88 }
89
90 decoder := json.NewDecoder(bytes.NewReader(b))
91 decoder.UseNumber()
92 if err := decoder.Decode(&jsonHeaders); err != nil {
93 return err
94 }
95
96 var headers Headers
97 for _, h := range jsonHeaders {
98 value, err := valueFromType(h.Type, h.Value)
99 if err != nil {
100 return err
101 }
102 headers.Set(h.Name, value)
103 }
104 (*hs) = decodedHeaders(headers)
105
106 return nil
107}
108
109func valueFromType(typ valueType, val interface{}) (Value, error) {
110 switch typ {
111 case trueValueType:
112 return BoolValue(true), nil
113 case falseValueType:
114 return BoolValue(false), nil
115 case int8ValueType:
116 v, err := val.(json.Number).Int64()
117 return Int8Value(int8(v)), err
118 case int16ValueType:
119 v, err := val.(json.Number).Int64()
120 return Int16Value(int16(v)), err
121 case int32ValueType:
122 v, err := val.(json.Number).Int64()
123 return Int32Value(int32(v)), err
124 case int64ValueType:
125 v, err := val.(json.Number).Int64()
126 return Int64Value(v), err
127 case bytesValueType:
128 v, err := base64.StdEncoding.DecodeString(val.(string))
129 return BytesValue(v), err
130 case stringValueType:
131 v, err := base64.StdEncoding.DecodeString(val.(string))
132 return StringValue(string(v)), err
133 case timestampValueType:
134 v, err := val.(json.Number).Int64()
135 return TimestampValue(timeFromEpochMilli(v)), err
136 case uuidValueType:
137 v, err := base64.StdEncoding.DecodeString(val.(string))
138 var tv UUIDValue
139 copy(tv[:], v)
140 return tv, err
141 default:
142 panic(fmt.Sprintf("unknown type, %s, %T", typ.String(), val))
143 }
144}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/decode.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/decode.go
new file mode 100644
index 0000000..4b972b2
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/decode.go
@@ -0,0 +1,199 @@
1package eventstream
2
3import (
4 "bytes"
5 "encoding/binary"
6 "encoding/hex"
7 "encoding/json"
8 "fmt"
9 "hash"
10 "hash/crc32"
11 "io"
12
13 "github.com/aws/aws-sdk-go/aws"
14)
15
16// Decoder provides decoding of an Event Stream messages.
17type Decoder struct {
18 r io.Reader
19 logger aws.Logger
20}
21
22// NewDecoder initializes and returns a Decoder for decoding event
23// stream messages from the reader provided.
24func NewDecoder(r io.Reader) *Decoder {
25 return &Decoder{
26 r: r,
27 }
28}
29
30// Decode attempts to decode a single message from the event stream reader.
31// Will return the event stream message, or error if Decode fails to read
32// the message from the stream.
33func (d *Decoder) Decode(payloadBuf []byte) (m Message, err error) {
34 reader := d.r
35 if d.logger != nil {
36 debugMsgBuf := bytes.NewBuffer(nil)
37 reader = io.TeeReader(reader, debugMsgBuf)
38 defer func() {
39 logMessageDecode(d.logger, debugMsgBuf, m, err)
40 }()
41 }
42
43 crc := crc32.New(crc32IEEETable)
44 hashReader := io.TeeReader(reader, crc)
45
46 prelude, err := decodePrelude(hashReader, crc)
47 if err != nil {
48 return Message{}, err
49 }
50
51 if prelude.HeadersLen > 0 {
52 lr := io.LimitReader(hashReader, int64(prelude.HeadersLen))
53 m.Headers, err = decodeHeaders(lr)
54 if err != nil {
55 return Message{}, err
56 }
57 }
58
59 if payloadLen := prelude.PayloadLen(); payloadLen > 0 {
60 buf, err := decodePayload(payloadBuf, io.LimitReader(hashReader, int64(payloadLen)))
61 if err != nil {
62 return Message{}, err
63 }
64 m.Payload = buf
65 }
66
67 msgCRC := crc.Sum32()
68 if err := validateCRC(reader, msgCRC); err != nil {
69 return Message{}, err
70 }
71
72 return m, nil
73}
74
75// UseLogger specifies the Logger that that the decoder should use to log the
76// message decode to.
77func (d *Decoder) UseLogger(logger aws.Logger) {
78 d.logger = logger
79}
80
81func logMessageDecode(logger aws.Logger, msgBuf *bytes.Buffer, msg Message, decodeErr error) {
82 w := bytes.NewBuffer(nil)
83 defer func() { logger.Log(w.String()) }()
84
85 fmt.Fprintf(w, "Raw message:\n%s\n",
86 hex.Dump(msgBuf.Bytes()))
87
88 if decodeErr != nil {
89 fmt.Fprintf(w, "Decode error: %v\n", decodeErr)
90 return
91 }
92
93 rawMsg, err := msg.rawMessage()
94 if err != nil {
95 fmt.Fprintf(w, "failed to create raw message, %v\n", err)
96 return
97 }
98
99 decodedMsg := decodedMessage{
100 rawMessage: rawMsg,
101 Headers: decodedHeaders(msg.Headers),
102 }
103
104 fmt.Fprintf(w, "Decoded message:\n")
105 encoder := json.NewEncoder(w)
106 if err := encoder.Encode(decodedMsg); err != nil {
107 fmt.Fprintf(w, "failed to generate decoded message, %v\n", err)
108 }
109}
110
111func decodePrelude(r io.Reader, crc hash.Hash32) (messagePrelude, error) {
112 var p messagePrelude
113
114 var err error
115 p.Length, err = decodeUint32(r)
116 if err != nil {
117 return messagePrelude{}, err
118 }
119
120 p.HeadersLen, err = decodeUint32(r)
121 if err != nil {
122 return messagePrelude{}, err
123 }
124
125 if err := p.ValidateLens(); err != nil {
126 return messagePrelude{}, err
127 }
128
129 preludeCRC := crc.Sum32()
130 if err := validateCRC(r, preludeCRC); err != nil {
131 return messagePrelude{}, err
132 }
133
134 p.PreludeCRC = preludeCRC
135
136 return p, nil
137}
138
139func decodePayload(buf []byte, r io.Reader) ([]byte, error) {
140 w := bytes.NewBuffer(buf[0:0])
141
142 _, err := io.Copy(w, r)
143 return w.Bytes(), err
144}
145
146func decodeUint8(r io.Reader) (uint8, error) {
147 type byteReader interface {
148 ReadByte() (byte, error)
149 }
150
151 if br, ok := r.(byteReader); ok {
152 v, err := br.ReadByte()
153 return uint8(v), err
154 }
155
156 var b [1]byte
157 _, err := io.ReadFull(r, b[:])
158 return uint8(b[0]), err
159}
160func decodeUint16(r io.Reader) (uint16, error) {
161 var b [2]byte
162 bs := b[:]
163 _, err := io.ReadFull(r, bs)
164 if err != nil {
165 return 0, err
166 }
167 return binary.BigEndian.Uint16(bs), nil
168}
169func decodeUint32(r io.Reader) (uint32, error) {
170 var b [4]byte
171 bs := b[:]
172 _, err := io.ReadFull(r, bs)
173 if err != nil {
174 return 0, err
175 }
176 return binary.BigEndian.Uint32(bs), nil
177}
178func decodeUint64(r io.Reader) (uint64, error) {
179 var b [8]byte
180 bs := b[:]
181 _, err := io.ReadFull(r, bs)
182 if err != nil {
183 return 0, err
184 }
185 return binary.BigEndian.Uint64(bs), nil
186}
187
188func validateCRC(r io.Reader, expect uint32) error {
189 msgCRC, err := decodeUint32(r)
190 if err != nil {
191 return err
192 }
193
194 if msgCRC != expect {
195 return ChecksumError{}
196 }
197
198 return nil
199}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/encode.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/encode.go
new file mode 100644
index 0000000..150a609
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/encode.go
@@ -0,0 +1,114 @@
1package eventstream
2
3import (
4 "bytes"
5 "encoding/binary"
6 "hash"
7 "hash/crc32"
8 "io"
9)
10
11// Encoder provides EventStream message encoding.
12type Encoder struct {
13 w io.Writer
14
15 headersBuf *bytes.Buffer
16}
17
18// NewEncoder initializes and returns an Encoder to encode Event Stream
19// messages to an io.Writer.
20func NewEncoder(w io.Writer) *Encoder {
21 return &Encoder{
22 w: w,
23 headersBuf: bytes.NewBuffer(nil),
24 }
25}
26
27// Encode encodes a single EventStream message to the io.Writer the Encoder
28// was created with. An error is returned if writing the message fails.
29func (e *Encoder) Encode(msg Message) error {
30 e.headersBuf.Reset()
31
32 err := encodeHeaders(e.headersBuf, msg.Headers)
33 if err != nil {
34 return err
35 }
36
37 crc := crc32.New(crc32IEEETable)
38 hashWriter := io.MultiWriter(e.w, crc)
39
40 headersLen := uint32(e.headersBuf.Len())
41 payloadLen := uint32(len(msg.Payload))
42
43 if err := encodePrelude(hashWriter, crc, headersLen, payloadLen); err != nil {
44 return err
45 }
46
47 if headersLen > 0 {
48 if _, err := io.Copy(hashWriter, e.headersBuf); err != nil {
49 return err
50 }
51 }
52
53 if payloadLen > 0 {
54 if _, err := hashWriter.Write(msg.Payload); err != nil {
55 return err
56 }
57 }
58
59 msgCRC := crc.Sum32()
60 return binary.Write(e.w, binary.BigEndian, msgCRC)
61}
62
63func encodePrelude(w io.Writer, crc hash.Hash32, headersLen, payloadLen uint32) error {
64 p := messagePrelude{
65 Length: minMsgLen + headersLen + payloadLen,
66 HeadersLen: headersLen,
67 }
68 if err := p.ValidateLens(); err != nil {
69 return err
70 }
71
72 err := binaryWriteFields(w, binary.BigEndian,
73 p.Length,
74 p.HeadersLen,
75 )
76 if err != nil {
77 return err
78 }
79
80 p.PreludeCRC = crc.Sum32()
81 err = binary.Write(w, binary.BigEndian, p.PreludeCRC)
82 if err != nil {
83 return err
84 }
85
86 return nil
87}
88
89func encodeHeaders(w io.Writer, headers Headers) error {
90 for _, h := range headers {
91 hn := headerName{
92 Len: uint8(len(h.Name)),
93 }
94 copy(hn.Name[:hn.Len], h.Name)
95 if err := hn.encode(w); err != nil {
96 return err
97 }
98
99 if err := h.Value.encode(w); err != nil {
100 return err
101 }
102 }
103
104 return nil
105}
106
107func binaryWriteFields(w io.Writer, order binary.ByteOrder, vs ...interface{}) error {
108 for _, v := range vs {
109 if err := binary.Write(w, order, v); err != nil {
110 return err
111 }
112 }
113 return nil
114}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/error.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/error.go
new file mode 100644
index 0000000..5481ef3
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/error.go
@@ -0,0 +1,23 @@
1package eventstream
2
3import "fmt"
4
5// LengthError provides the error for items being larger than a maximum length.
6type LengthError struct {
7 Part string
8 Want int
9 Have int
10 Value interface{}
11}
12
13func (e LengthError) Error() string {
14 return fmt.Sprintf("%s length invalid, %d/%d, %v",
15 e.Part, e.Want, e.Have, e.Value)
16}
17
18// ChecksumError provides the error for message checksum invalidation errors.
19type ChecksumError struct{}
20
21func (e ChecksumError) Error() string {
22 return "message checksum mismatch"
23}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/api.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/api.go
new file mode 100644
index 0000000..97937c8
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/api.go
@@ -0,0 +1,196 @@
1package eventstreamapi
2
3import (
4 "fmt"
5 "io"
6
7 "github.com/aws/aws-sdk-go/aws"
8 "github.com/aws/aws-sdk-go/private/protocol"
9 "github.com/aws/aws-sdk-go/private/protocol/eventstream"
10)
11
12// Unmarshaler provides the interface for unmarshaling a EventStream
13// message into a SDK type.
14type Unmarshaler interface {
15 UnmarshalEvent(protocol.PayloadUnmarshaler, eventstream.Message) error
16}
17
18// EventStream headers with specific meaning to async API functionality.
19const (
20 MessageTypeHeader = `:message-type` // Identifies type of message.
21 EventMessageType = `event`
22 ErrorMessageType = `error`
23 ExceptionMessageType = `exception`
24
25 // Message Events
26 EventTypeHeader = `:event-type` // Identifies message event type e.g. "Stats".
27
28 // Message Error
29 ErrorCodeHeader = `:error-code`
30 ErrorMessageHeader = `:error-message`
31
32 // Message Exception
33 ExceptionTypeHeader = `:exception-type`
34)
35
36// EventReader provides reading from the EventStream of an reader.
37type EventReader struct {
38 reader io.ReadCloser
39 decoder *eventstream.Decoder
40
41 unmarshalerForEventType func(string) (Unmarshaler, error)
42 payloadUnmarshaler protocol.PayloadUnmarshaler
43
44 payloadBuf []byte
45}
46
47// NewEventReader returns a EventReader built from the reader and unmarshaler
48// provided. Use ReadStream method to start reading from the EventStream.
49func NewEventReader(
50 reader io.ReadCloser,
51 payloadUnmarshaler protocol.PayloadUnmarshaler,
52 unmarshalerForEventType func(string) (Unmarshaler, error),
53) *EventReader {
54 return &EventReader{
55 reader: reader,
56 decoder: eventstream.NewDecoder(reader),
57 payloadUnmarshaler: payloadUnmarshaler,
58 unmarshalerForEventType: unmarshalerForEventType,
59 payloadBuf: make([]byte, 10*1024),
60 }
61}
62
63// UseLogger instructs the EventReader to use the logger and log level
64// specified.
65func (r *EventReader) UseLogger(logger aws.Logger, logLevel aws.LogLevelType) {
66 if logger != nil && logLevel.Matches(aws.LogDebugWithEventStreamBody) {
67 r.decoder.UseLogger(logger)
68 }
69}
70
71// ReadEvent attempts to read a message from the EventStream and return the
72// unmarshaled event value that the message is for.
73//
74// For EventStream API errors check if the returned error satisfies the
75// awserr.Error interface to get the error's Code and Message components.
76//
77// EventUnmarshalers called with EventStream messages must take copies of the
78// message's Payload. The payload will is reused between events read.
79func (r *EventReader) ReadEvent() (event interface{}, err error) {
80 msg, err := r.decoder.Decode(r.payloadBuf)
81 if err != nil {
82 return nil, err
83 }
84 defer func() {
85 // Reclaim payload buffer for next message read.
86 r.payloadBuf = msg.Payload[0:0]
87 }()
88
89 typ, err := GetHeaderString(msg, MessageTypeHeader)
90 if err != nil {
91 return nil, err
92 }
93
94 switch typ {
95 case EventMessageType:
96 return r.unmarshalEventMessage(msg)
97 case ExceptionMessageType:
98 err = r.unmarshalEventException(msg)
99 return nil, err
100 case ErrorMessageType:
101 return nil, r.unmarshalErrorMessage(msg)
102 default:
103 return nil, fmt.Errorf("unknown eventstream message type, %v", typ)
104 }
105}
106
107func (r *EventReader) unmarshalEventMessage(
108 msg eventstream.Message,
109) (event interface{}, err error) {
110 eventType, err := GetHeaderString(msg, EventTypeHeader)
111 if err != nil {
112 return nil, err
113 }
114
115 ev, err := r.unmarshalerForEventType(eventType)
116 if err != nil {
117 return nil, err
118 }
119
120 err = ev.UnmarshalEvent(r.payloadUnmarshaler, msg)
121 if err != nil {
122 return nil, err
123 }
124
125 return ev, nil
126}
127
128func (r *EventReader) unmarshalEventException(
129 msg eventstream.Message,
130) (err error) {
131 eventType, err := GetHeaderString(msg, ExceptionTypeHeader)
132 if err != nil {
133 return err
134 }
135
136 ev, err := r.unmarshalerForEventType(eventType)
137 if err != nil {
138 return err
139 }
140
141 err = ev.UnmarshalEvent(r.payloadUnmarshaler, msg)
142 if err != nil {
143 return err
144 }
145
146 var ok bool
147 err, ok = ev.(error)
148 if !ok {
149 err = messageError{
150 code: "SerializationError",
151 msg: fmt.Sprintf(
152 "event stream exception %s mapped to non-error %T, %v",
153 eventType, ev, ev,
154 ),
155 }
156 }
157
158 return err
159}
160
161func (r *EventReader) unmarshalErrorMessage(msg eventstream.Message) (err error) {
162 var msgErr messageError
163
164 msgErr.code, err = GetHeaderString(msg, ErrorCodeHeader)
165 if err != nil {
166 return err
167 }
168
169 msgErr.msg, err = GetHeaderString(msg, ErrorMessageHeader)
170 if err != nil {
171 return err
172 }
173
174 return msgErr
175}
176
177// Close closes the EventReader's EventStream reader.
178func (r *EventReader) Close() error {
179 return r.reader.Close()
180}
181
182// GetHeaderString returns the value of the header as a string. If the header
183// is not set or the value is not a string an error will be returned.
184func GetHeaderString(msg eventstream.Message, headerName string) (string, error) {
185 headerVal := msg.Headers.Get(headerName)
186 if headerVal == nil {
187 return "", fmt.Errorf("error header %s not present", headerName)
188 }
189
190 v, ok := headerVal.Get().(string)
191 if !ok {
192 return "", fmt.Errorf("error header value is not a string, %T", headerVal)
193 }
194
195 return v, nil
196}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/error.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/error.go
new file mode 100644
index 0000000..5ea5a98
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi/error.go
@@ -0,0 +1,24 @@
1package eventstreamapi
2
3import "fmt"
4
5type messageError struct {
6 code string
7 msg string
8}
9
10func (e messageError) Code() string {
11 return e.code
12}
13
14func (e messageError) Message() string {
15 return e.msg
16}
17
18func (e messageError) Error() string {
19 return fmt.Sprintf("%s: %s", e.code, e.msg)
20}
21
22func (e messageError) OrigErr() error {
23 return nil
24}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header.go
new file mode 100644
index 0000000..3b44dde
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header.go
@@ -0,0 +1,166 @@
1package eventstream
2
3import (
4 "encoding/binary"
5 "fmt"
6 "io"
7)
8
9// Headers are a collection of EventStream header values.
10type Headers []Header
11
12// Header is a single EventStream Key Value header pair.
13type Header struct {
14 Name string
15 Value Value
16}
17
18// Set associates the name with a value. If the header name already exists in
19// the Headers the value will be replaced with the new one.
20func (hs *Headers) Set(name string, value Value) {
21 var i int
22 for ; i < len(*hs); i++ {
23 if (*hs)[i].Name == name {
24 (*hs)[i].Value = value
25 return
26 }
27 }
28
29 *hs = append(*hs, Header{
30 Name: name, Value: value,
31 })
32}
33
34// Get returns the Value associated with the header. Nil is returned if the
35// value does not exist.
36func (hs Headers) Get(name string) Value {
37 for i := 0; i < len(hs); i++ {
38 if h := hs[i]; h.Name == name {
39 return h.Value
40 }
41 }
42 return nil
43}
44
45// Del deletes the value in the Headers if it exists.
46func (hs *Headers) Del(name string) {
47 for i := 0; i < len(*hs); i++ {
48 if (*hs)[i].Name == name {
49 copy((*hs)[i:], (*hs)[i+1:])
50 (*hs) = (*hs)[:len(*hs)-1]
51 }
52 }
53}
54
55func decodeHeaders(r io.Reader) (Headers, error) {
56 hs := Headers{}
57
58 for {
59 name, err := decodeHeaderName(r)
60 if err != nil {
61 if err == io.EOF {
62 // EOF while getting header name means no more headers
63 break
64 }
65 return nil, err
66 }
67
68 value, err := decodeHeaderValue(r)
69 if err != nil {
70 return nil, err
71 }
72
73 hs.Set(name, value)
74 }
75
76 return hs, nil
77}
78
79func decodeHeaderName(r io.Reader) (string, error) {
80 var n headerName
81
82 var err error
83 n.Len, err = decodeUint8(r)
84 if err != nil {
85 return "", err
86 }
87
88 name := n.Name[:n.Len]
89 if _, err := io.ReadFull(r, name); err != nil {
90 return "", err
91 }
92
93 return string(name), nil
94}
95
96func decodeHeaderValue(r io.Reader) (Value, error) {
97 var raw rawValue
98
99 typ, err := decodeUint8(r)
100 if err != nil {
101 return nil, err
102 }
103 raw.Type = valueType(typ)
104
105 var v Value
106
107 switch raw.Type {
108 case trueValueType:
109 v = BoolValue(true)
110 case falseValueType:
111 v = BoolValue(false)
112 case int8ValueType:
113 var tv Int8Value
114 err = tv.decode(r)
115 v = tv
116 case int16ValueType:
117 var tv Int16Value
118 err = tv.decode(r)
119 v = tv
120 case int32ValueType:
121 var tv Int32Value
122 err = tv.decode(r)
123 v = tv
124 case int64ValueType:
125 var tv Int64Value
126 err = tv.decode(r)
127 v = tv
128 case bytesValueType:
129 var tv BytesValue
130 err = tv.decode(r)
131 v = tv
132 case stringValueType:
133 var tv StringValue
134 err = tv.decode(r)
135 v = tv
136 case timestampValueType:
137 var tv TimestampValue
138 err = tv.decode(r)
139 v = tv
140 case uuidValueType:
141 var tv UUIDValue
142 err = tv.decode(r)
143 v = tv
144 default:
145 panic(fmt.Sprintf("unknown value type %d", raw.Type))
146 }
147
148 // Error could be EOF, let caller deal with it
149 return v, err
150}
151
152const maxHeaderNameLen = 255
153
154type headerName struct {
155 Len uint8
156 Name [maxHeaderNameLen]byte
157}
158
159func (v headerName) encode(w io.Writer) error {
160 if err := binary.Write(w, binary.BigEndian, v.Len); err != nil {
161 return err
162 }
163
164 _, err := w.Write(v.Name[:v.Len])
165 return err
166}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header_value.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header_value.go
new file mode 100644
index 0000000..e3fc076
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/header_value.go
@@ -0,0 +1,501 @@
1package eventstream
2
3import (
4 "encoding/base64"
5 "encoding/binary"
6 "fmt"
7 "io"
8 "strconv"
9 "time"
10)
11
12const maxHeaderValueLen = 1<<15 - 1 // 2^15-1 or 32KB - 1
13
14// valueType is the EventStream header value type.
15type valueType uint8
16
17// Header value types
18const (
19 trueValueType valueType = iota
20 falseValueType
21 int8ValueType // Byte
22 int16ValueType // Short
23 int32ValueType // Integer
24 int64ValueType // Long
25 bytesValueType
26 stringValueType
27 timestampValueType
28 uuidValueType
29)
30
31func (t valueType) String() string {
32 switch t {
33 case trueValueType:
34 return "bool"
35 case falseValueType:
36 return "bool"
37 case int8ValueType:
38 return "int8"
39 case int16ValueType:
40 return "int16"
41 case int32ValueType:
42 return "int32"
43 case int64ValueType:
44 return "int64"
45 case bytesValueType:
46 return "byte_array"
47 case stringValueType:
48 return "string"
49 case timestampValueType:
50 return "timestamp"
51 case uuidValueType:
52 return "uuid"
53 default:
54 return fmt.Sprintf("unknown value type %d", uint8(t))
55 }
56}
57
58type rawValue struct {
59 Type valueType
60 Len uint16 // Only set for variable length slices
61 Value []byte // byte representation of value, BigEndian encoding.
62}
63
64func (r rawValue) encodeScalar(w io.Writer, v interface{}) error {
65 return binaryWriteFields(w, binary.BigEndian,
66 r.Type,
67 v,
68 )
69}
70
71func (r rawValue) encodeFixedSlice(w io.Writer, v []byte) error {
72 binary.Write(w, binary.BigEndian, r.Type)
73
74 _, err := w.Write(v)
75 return err
76}
77
78func (r rawValue) encodeBytes(w io.Writer, v []byte) error {
79 if len(v) > maxHeaderValueLen {
80 return LengthError{
81 Part: "header value",
82 Want: maxHeaderValueLen, Have: len(v),
83 Value: v,
84 }
85 }
86 r.Len = uint16(len(v))
87
88 err := binaryWriteFields(w, binary.BigEndian,
89 r.Type,
90 r.Len,
91 )
92 if err != nil {
93 return err
94 }
95
96 _, err = w.Write(v)
97 return err
98}
99
100func (r rawValue) encodeString(w io.Writer, v string) error {
101 if len(v) > maxHeaderValueLen {
102 return LengthError{
103 Part: "header value",
104 Want: maxHeaderValueLen, Have: len(v),
105 Value: v,
106 }
107 }
108 r.Len = uint16(len(v))
109
110 type stringWriter interface {
111 WriteString(string) (int, error)
112 }
113
114 err := binaryWriteFields(w, binary.BigEndian,
115 r.Type,
116 r.Len,
117 )
118 if err != nil {
119 return err
120 }
121
122 if sw, ok := w.(stringWriter); ok {
123 _, err = sw.WriteString(v)
124 } else {
125 _, err = w.Write([]byte(v))
126 }
127
128 return err
129}
130
131func decodeFixedBytesValue(r io.Reader, buf []byte) error {
132 _, err := io.ReadFull(r, buf)
133 return err
134}
135
136func decodeBytesValue(r io.Reader) ([]byte, error) {
137 var raw rawValue
138 var err error
139 raw.Len, err = decodeUint16(r)
140 if err != nil {
141 return nil, err
142 }
143
144 buf := make([]byte, raw.Len)
145 _, err = io.ReadFull(r, buf)
146 if err != nil {
147 return nil, err
148 }
149
150 return buf, nil
151}
152
153func decodeStringValue(r io.Reader) (string, error) {
154 v, err := decodeBytesValue(r)
155 return string(v), err
156}
157
158// Value represents the abstract header value.
159type Value interface {
160 Get() interface{}
161 String() string
162 valueType() valueType
163 encode(io.Writer) error
164}
165
166// An BoolValue provides eventstream encoding, and representation
167// of a Go bool value.
168type BoolValue bool
169
170// Get returns the underlying type
171func (v BoolValue) Get() interface{} {
172 return bool(v)
173}
174
175// valueType returns the EventStream header value type value.
176func (v BoolValue) valueType() valueType {
177 if v {
178 return trueValueType
179 }
180 return falseValueType
181}
182
183func (v BoolValue) String() string {
184 return strconv.FormatBool(bool(v))
185}
186
187// encode encodes the BoolValue into an eventstream binary value
188// representation.
189func (v BoolValue) encode(w io.Writer) error {
190 return binary.Write(w, binary.BigEndian, v.valueType())
191}
192
193// An Int8Value provides eventstream encoding, and representation of a Go
194// int8 value.
195type Int8Value int8
196
197// Get returns the underlying value.
198func (v Int8Value) Get() interface{} {
199 return int8(v)
200}
201
202// valueType returns the EventStream header value type value.
203func (Int8Value) valueType() valueType {
204 return int8ValueType
205}
206
207func (v Int8Value) String() string {
208 return fmt.Sprintf("0x%02x", int8(v))
209}
210
211// encode encodes the Int8Value into an eventstream binary value
212// representation.
213func (v Int8Value) encode(w io.Writer) error {
214 raw := rawValue{
215 Type: v.valueType(),
216 }
217
218 return raw.encodeScalar(w, v)
219}
220
221func (v *Int8Value) decode(r io.Reader) error {
222 n, err := decodeUint8(r)
223 if err != nil {
224 return err
225 }
226
227 *v = Int8Value(n)
228 return nil
229}
230
231// An Int16Value provides eventstream encoding, and representation of a Go
232// int16 value.
233type Int16Value int16
234
235// Get returns the underlying value.
236func (v Int16Value) Get() interface{} {
237 return int16(v)
238}
239
240// valueType returns the EventStream header value type value.
241func (Int16Value) valueType() valueType {
242 return int16ValueType
243}
244
245func (v Int16Value) String() string {
246 return fmt.Sprintf("0x%04x", int16(v))
247}
248
249// encode encodes the Int16Value into an eventstream binary value
250// representation.
251func (v Int16Value) encode(w io.Writer) error {
252 raw := rawValue{
253 Type: v.valueType(),
254 }
255 return raw.encodeScalar(w, v)
256}
257
258func (v *Int16Value) decode(r io.Reader) error {
259 n, err := decodeUint16(r)
260 if err != nil {
261 return err
262 }
263
264 *v = Int16Value(n)
265 return nil
266}
267
268// An Int32Value provides eventstream encoding, and representation of a Go
269// int32 value.
270type Int32Value int32
271
272// Get returns the underlying value.
273func (v Int32Value) Get() interface{} {
274 return int32(v)
275}
276
277// valueType returns the EventStream header value type value.
278func (Int32Value) valueType() valueType {
279 return int32ValueType
280}
281
282func (v Int32Value) String() string {
283 return fmt.Sprintf("0x%08x", int32(v))
284}
285
286// encode encodes the Int32Value into an eventstream binary value
287// representation.
288func (v Int32Value) encode(w io.Writer) error {
289 raw := rawValue{
290 Type: v.valueType(),
291 }
292 return raw.encodeScalar(w, v)
293}
294
295func (v *Int32Value) decode(r io.Reader) error {
296 n, err := decodeUint32(r)
297 if err != nil {
298 return err
299 }
300
301 *v = Int32Value(n)
302 return nil
303}
304
305// An Int64Value provides eventstream encoding, and representation of a Go
306// int64 value.
307type Int64Value int64
308
309// Get returns the underlying value.
310func (v Int64Value) Get() interface{} {
311 return int64(v)
312}
313
314// valueType returns the EventStream header value type value.
315func (Int64Value) valueType() valueType {
316 return int64ValueType
317}
318
319func (v Int64Value) String() string {
320 return fmt.Sprintf("0x%016x", int64(v))
321}
322
323// encode encodes the Int64Value into an eventstream binary value
324// representation.
325func (v Int64Value) encode(w io.Writer) error {
326 raw := rawValue{
327 Type: v.valueType(),
328 }
329 return raw.encodeScalar(w, v)
330}
331
332func (v *Int64Value) decode(r io.Reader) error {
333 n, err := decodeUint64(r)
334 if err != nil {
335 return err
336 }
337
338 *v = Int64Value(n)
339 return nil
340}
341
342// An BytesValue provides eventstream encoding, and representation of a Go
343// byte slice.
344type BytesValue []byte
345
346// Get returns the underlying value.
347func (v BytesValue) Get() interface{} {
348 return []byte(v)
349}
350
351// valueType returns the EventStream header value type value.
352func (BytesValue) valueType() valueType {
353 return bytesValueType
354}
355
356func (v BytesValue) String() string {
357 return base64.StdEncoding.EncodeToString([]byte(v))
358}
359
360// encode encodes the BytesValue into an eventstream binary value
361// representation.
362func (v BytesValue) encode(w io.Writer) error {
363 raw := rawValue{
364 Type: v.valueType(),
365 }
366
367 return raw.encodeBytes(w, []byte(v))
368}
369
370func (v *BytesValue) decode(r io.Reader) error {
371 buf, err := decodeBytesValue(r)
372 if err != nil {
373 return err
374 }
375
376 *v = BytesValue(buf)
377 return nil
378}
379
380// An StringValue provides eventstream encoding, and representation of a Go
381// string.
382type StringValue string
383
384// Get returns the underlying value.
385func (v StringValue) Get() interface{} {
386 return string(v)
387}
388
389// valueType returns the EventStream header value type value.
390func (StringValue) valueType() valueType {
391 return stringValueType
392}
393
394func (v StringValue) String() string {
395 return string(v)
396}
397
398// encode encodes the StringValue into an eventstream binary value
399// representation.
400func (v StringValue) encode(w io.Writer) error {
401 raw := rawValue{
402 Type: v.valueType(),
403 }
404
405 return raw.encodeString(w, string(v))
406}
407
408func (v *StringValue) decode(r io.Reader) error {
409 s, err := decodeStringValue(r)
410 if err != nil {
411 return err
412 }
413
414 *v = StringValue(s)
415 return nil
416}
417
418// An TimestampValue provides eventstream encoding, and representation of a Go
419// timestamp.
420type TimestampValue time.Time
421
422// Get returns the underlying value.
423func (v TimestampValue) Get() interface{} {
424 return time.Time(v)
425}
426
427// valueType returns the EventStream header value type value.
428func (TimestampValue) valueType() valueType {
429 return timestampValueType
430}
431
432func (v TimestampValue) epochMilli() int64 {
433 nano := time.Time(v).UnixNano()
434 msec := nano / int64(time.Millisecond)
435 return msec
436}
437
438func (v TimestampValue) String() string {
439 msec := v.epochMilli()
440 return strconv.FormatInt(msec, 10)
441}
442
443// encode encodes the TimestampValue into an eventstream binary value
444// representation.
445func (v TimestampValue) encode(w io.Writer) error {
446 raw := rawValue{
447 Type: v.valueType(),
448 }
449
450 msec := v.epochMilli()
451 return raw.encodeScalar(w, msec)
452}
453
454func (v *TimestampValue) decode(r io.Reader) error {
455 n, err := decodeUint64(r)
456 if err != nil {
457 return err
458 }
459
460 *v = TimestampValue(timeFromEpochMilli(int64(n)))
461 return nil
462}
463
464func timeFromEpochMilli(t int64) time.Time {
465 secs := t / 1e3
466 msec := t % 1e3
467 return time.Unix(secs, msec*int64(time.Millisecond)).UTC()
468}
469
470// An UUIDValue provides eventstream encoding, and representation of a UUID
471// value.
472type UUIDValue [16]byte
473
474// Get returns the underlying value.
475func (v UUIDValue) Get() interface{} {
476 return v[:]
477}
478
479// valueType returns the EventStream header value type value.
480func (UUIDValue) valueType() valueType {
481 return uuidValueType
482}
483
484func (v UUIDValue) String() string {
485 return fmt.Sprintf(`%X-%X-%X-%X-%X`, v[0:4], v[4:6], v[6:8], v[8:10], v[10:])
486}
487
488// encode encodes the UUIDValue into an eventstream binary value
489// representation.
490func (v UUIDValue) encode(w io.Writer) error {
491 raw := rawValue{
492 Type: v.valueType(),
493 }
494
495 return raw.encodeFixedSlice(w, v[:])
496}
497
498func (v *UUIDValue) decode(r io.Reader) error {
499 tv := (*v)[:]
500 return decodeFixedBytesValue(r, tv)
501}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/message.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/message.go
new file mode 100644
index 0000000..2dc012a
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/eventstream/message.go
@@ -0,0 +1,103 @@
1package eventstream
2
3import (
4 "bytes"
5 "encoding/binary"
6 "hash/crc32"
7)
8
9const preludeLen = 8
10const preludeCRCLen = 4
11const msgCRCLen = 4
12const minMsgLen = preludeLen + preludeCRCLen + msgCRCLen
13const maxPayloadLen = 1024 * 1024 * 16 // 16MB
14const maxHeadersLen = 1024 * 128 // 128KB
15const maxMsgLen = minMsgLen + maxHeadersLen + maxPayloadLen
16
17var crc32IEEETable = crc32.MakeTable(crc32.IEEE)
18
19// A Message provides the eventstream message representation.
20type Message struct {
21 Headers Headers
22 Payload []byte
23}
24
25func (m *Message) rawMessage() (rawMessage, error) {
26 var raw rawMessage
27
28 if len(m.Headers) > 0 {
29 var headers bytes.Buffer
30 if err := encodeHeaders(&headers, m.Headers); err != nil {
31 return rawMessage{}, err
32 }
33 raw.Headers = headers.Bytes()
34 raw.HeadersLen = uint32(len(raw.Headers))
35 }
36
37 raw.Length = raw.HeadersLen + uint32(len(m.Payload)) + minMsgLen
38
39 hash := crc32.New(crc32IEEETable)
40 binaryWriteFields(hash, binary.BigEndian, raw.Length, raw.HeadersLen)
41 raw.PreludeCRC = hash.Sum32()
42
43 binaryWriteFields(hash, binary.BigEndian, raw.PreludeCRC)
44
45 if raw.HeadersLen > 0 {
46 hash.Write(raw.Headers)
47 }
48
49 // Read payload bytes and update hash for it as well.
50 if len(m.Payload) > 0 {
51 raw.Payload = m.Payload
52 hash.Write(raw.Payload)
53 }
54
55 raw.CRC = hash.Sum32()
56
57 return raw, nil
58}
59
60type messagePrelude struct {
61 Length uint32
62 HeadersLen uint32
63 PreludeCRC uint32
64}
65
66func (p messagePrelude) PayloadLen() uint32 {
67 return p.Length - p.HeadersLen - minMsgLen
68}
69
70func (p messagePrelude) ValidateLens() error {
71 if p.Length == 0 || p.Length > maxMsgLen {
72 return LengthError{
73 Part: "message prelude",
74 Want: maxMsgLen,
75 Have: int(p.Length),
76 }
77 }
78 if p.HeadersLen > maxHeadersLen {
79 return LengthError{
80 Part: "message headers",
81 Want: maxHeadersLen,
82 Have: int(p.HeadersLen),
83 }
84 }
85 if payloadLen := p.PayloadLen(); payloadLen > maxPayloadLen {
86 return LengthError{
87 Part: "message payload",
88 Want: maxPayloadLen,
89 Have: int(payloadLen),
90 }
91 }
92
93 return nil
94}
95
96type rawMessage struct {
97 messagePrelude
98
99 Headers []byte
100 Payload []byte
101
102 CRC uint32
103}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/jsonvalue.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/jsonvalue.go
new file mode 100644
index 0000000..776d110
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/jsonvalue.go
@@ -0,0 +1,76 @@
1package protocol
2
3import (
4 "encoding/base64"
5 "encoding/json"
6 "fmt"
7 "strconv"
8
9 "github.com/aws/aws-sdk-go/aws"
10)
11
12// EscapeMode is the mode that should be use for escaping a value
13type EscapeMode uint
14
15// The modes for escaping a value before it is marshaled, and unmarshaled.
16const (
17 NoEscape EscapeMode = iota
18 Base64Escape
19 QuotedEscape
20)
21
22// EncodeJSONValue marshals the value into a JSON string, and optionally base64
23// encodes the string before returning it.
24//
25// Will panic if the escape mode is unknown.
26func EncodeJSONValue(v aws.JSONValue, escape EscapeMode) (string, error) {
27 b, err := json.Marshal(v)
28 if err != nil {
29 return "", err
30 }
31
32 switch escape {
33 case NoEscape:
34 return string(b), nil
35 case Base64Escape:
36 return base64.StdEncoding.EncodeToString(b), nil
37 case QuotedEscape:
38 return strconv.Quote(string(b)), nil
39 }
40
41 panic(fmt.Sprintf("EncodeJSONValue called with unknown EscapeMode, %v", escape))
42}
43
44// DecodeJSONValue will attempt to decode the string input as a JSONValue.
45// Optionally decoding base64 the value first before JSON unmarshaling.
46//
47// Will panic if the escape mode is unknown.
48func DecodeJSONValue(v string, escape EscapeMode) (aws.JSONValue, error) {
49 var b []byte
50 var err error
51
52 switch escape {
53 case NoEscape:
54 b = []byte(v)
55 case Base64Escape:
56 b, err = base64.StdEncoding.DecodeString(v)
57 case QuotedEscape:
58 var u string
59 u, err = strconv.Unquote(v)
60 b = []byte(u)
61 default:
62 panic(fmt.Sprintf("DecodeJSONValue called with unknown EscapeMode, %v", escape))
63 }
64
65 if err != nil {
66 return nil, err
67 }
68
69 m := aws.JSONValue{}
70 err = json.Unmarshal(b, &m)
71 if err != nil {
72 return nil, err
73 }
74
75 return m, nil
76}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/payload.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/payload.go
new file mode 100644
index 0000000..e21614a
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/payload.go
@@ -0,0 +1,81 @@
1package protocol
2
3import (
4 "io"
5 "io/ioutil"
6 "net/http"
7
8 "github.com/aws/aws-sdk-go/aws"
9 "github.com/aws/aws-sdk-go/aws/client/metadata"
10 "github.com/aws/aws-sdk-go/aws/request"
11)
12
13// PayloadUnmarshaler provides the interface for unmarshaling a payload's
14// reader into a SDK shape.
15type PayloadUnmarshaler interface {
16 UnmarshalPayload(io.Reader, interface{}) error
17}
18
19// HandlerPayloadUnmarshal implements the PayloadUnmarshaler from a
20// HandlerList. This provides the support for unmarshaling a payload reader to
21// a shape without needing a SDK request first.
22type HandlerPayloadUnmarshal struct {
23 Unmarshalers request.HandlerList
24}
25
26// UnmarshalPayload unmarshals the io.Reader payload into the SDK shape using
27// the Unmarshalers HandlerList provided. Returns an error if unable
28// unmarshaling fails.
29func (h HandlerPayloadUnmarshal) UnmarshalPayload(r io.Reader, v interface{}) error {
30 req := &request.Request{
31 HTTPRequest: &http.Request{},
32 HTTPResponse: &http.Response{
33 StatusCode: 200,
34 Header: http.Header{},
35 Body: ioutil.NopCloser(r),
36 },
37 Data: v,
38 }
39
40 h.Unmarshalers.Run(req)
41
42 return req.Error
43}
44
45// PayloadMarshaler provides the interface for marshaling a SDK shape into and
46// io.Writer.
47type PayloadMarshaler interface {
48 MarshalPayload(io.Writer, interface{}) error
49}
50
51// HandlerPayloadMarshal implements the PayloadMarshaler from a HandlerList.
52// This provides support for marshaling a SDK shape into an io.Writer without
53// needing a SDK request first.
54type HandlerPayloadMarshal struct {
55 Marshalers request.HandlerList
56}
57
58// MarshalPayload marshals the SDK shape into the io.Writer using the
59// Marshalers HandlerList provided. Returns an error if unable if marshal
60// fails.
61func (h HandlerPayloadMarshal) MarshalPayload(w io.Writer, v interface{}) error {
62 req := request.New(
63 aws.Config{},
64 metadata.ClientInfo{},
65 request.Handlers{},
66 nil,
67 &request.Operation{HTTPMethod: "GET"},
68 v,
69 nil,
70 )
71
72 h.Marshalers.Run(req)
73
74 if req.Error != nil {
75 return req.Error
76 }
77
78 io.Copy(w, req.GetBody())
79
80 return nil
81}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go
index 18169f0..60e5b09 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go
@@ -25,7 +25,7 @@ func Build(r *request.Request) {
25 return 25 return
26 } 26 }
27 27
28 if r.ExpireTime == 0 { 28 if !r.IsPresigned() {
29 r.HTTPRequest.Method = "POST" 29 r.HTTPRequest.Method = "POST"
30 r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") 30 r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
31 r.SetBufferBody([]byte(body.Encode())) 31 r.SetBufferBody([]byte(body.Encode()))
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go
index 524ca95..75866d0 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go
@@ -121,6 +121,10 @@ func (q *queryParser) parseList(v url.Values, value reflect.Value, prefix string
121 return nil 121 return nil
122 } 122 }
123 123
124 if _, ok := value.Interface().([]byte); ok {
125 return q.parseScalar(v, value, prefix, tag)
126 }
127
124 // check for unflattened list member 128 // check for unflattened list member
125 if !q.isEC2 && tag.Get("flattened") == "" { 129 if !q.isEC2 && tag.Get("flattened") == "" {
126 if listName := tag.Get("locationNameList"); listName == "" { 130 if listName := tag.Get("locationNameList"); listName == "" {
@@ -229,7 +233,12 @@ func (q *queryParser) parseScalar(v url.Values, r reflect.Value, name string, ta
229 v.Set(name, strconv.FormatFloat(float64(value), 'f', -1, 32)) 233 v.Set(name, strconv.FormatFloat(float64(value), 'f', -1, 32))
230 case time.Time: 234 case time.Time:
231 const ISO8601UTC = "2006-01-02T15:04:05Z" 235 const ISO8601UTC = "2006-01-02T15:04:05Z"
232 v.Set(name, value.UTC().Format(ISO8601UTC)) 236 format := tag.Get("timestampFormat")
237 if len(format) == 0 {
238 format = protocol.ISO8601TimeFormatName
239 }
240
241 v.Set(name, protocol.FormatTime(format, value))
233 default: 242 default:
234 return fmt.Errorf("unsupported value for param %s: %v (%s)", name, r.Interface(), r.Type().Name()) 243 return fmt.Errorf("unsupported value for param %s: %v (%s)", name, r.Interface(), r.Type().Name())
235 } 244 }
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go
index 7161835..b34f525 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go
@@ -4,7 +4,6 @@ package rest
4import ( 4import (
5 "bytes" 5 "bytes"
6 "encoding/base64" 6 "encoding/base64"
7 "encoding/json"
8 "fmt" 7 "fmt"
9 "io" 8 "io"
10 "net/http" 9 "net/http"
@@ -18,11 +17,9 @@ import (
18 "github.com/aws/aws-sdk-go/aws" 17 "github.com/aws/aws-sdk-go/aws"
19 "github.com/aws/aws-sdk-go/aws/awserr" 18 "github.com/aws/aws-sdk-go/aws/awserr"
20 "github.com/aws/aws-sdk-go/aws/request" 19 "github.com/aws/aws-sdk-go/aws/request"
20 "github.com/aws/aws-sdk-go/private/protocol"
21) 21)
22 22
23// RFC822 returns an RFC822 formatted timestamp for AWS protocols
24const RFC822 = "Mon, 2 Jan 2006 15:04:05 GMT"
25
26// Whether the byte value can be sent without escaping in AWS URLs 23// Whether the byte value can be sent without escaping in AWS URLs
27var noEscape [256]bool 24var noEscape [256]bool
28 25
@@ -252,13 +249,12 @@ func EscapePath(path string, encodeSep bool) string {
252 return buf.String() 249 return buf.String()
253} 250}
254 251
255func convertType(v reflect.Value, tag reflect.StructTag) (string, error) { 252func convertType(v reflect.Value, tag reflect.StructTag) (str string, err error) {
256 v = reflect.Indirect(v) 253 v = reflect.Indirect(v)
257 if !v.IsValid() { 254 if !v.IsValid() {
258 return "", errValueNotSet 255 return "", errValueNotSet
259 } 256 }
260 257
261 var str string
262 switch value := v.Interface().(type) { 258 switch value := v.Interface().(type) {
263 case string: 259 case string:
264 str = value 260 str = value
@@ -271,19 +267,28 @@ func convertType(v reflect.Value, tag reflect.StructTag) (string, error) {
271 case float64: 267 case float64:
272 str = strconv.FormatFloat(value, 'f', -1, 64) 268 str = strconv.FormatFloat(value, 'f', -1, 64)
273 case time.Time: 269 case time.Time:
274 str = value.UTC().Format(RFC822) 270 format := tag.Get("timestampFormat")
271 if len(format) == 0 {
272 format = protocol.RFC822TimeFormatName
273 if tag.Get("location") == "querystring" {
274 format = protocol.ISO8601TimeFormatName
275 }
276 }
277 str = protocol.FormatTime(format, value)
275 case aws.JSONValue: 278 case aws.JSONValue:
276 b, err := json.Marshal(value) 279 if len(value) == 0 {
277 if err != nil { 280 return "", errValueNotSet
278 return "", err
279 } 281 }
282 escaping := protocol.NoEscape
280 if tag.Get("location") == "header" { 283 if tag.Get("location") == "header" {
281 str = base64.StdEncoding.EncodeToString(b) 284 escaping = protocol.Base64Escape
282 } else { 285 }
283 str = string(b) 286 str, err = protocol.EncodeJSONValue(value, escaping)
287 if err != nil {
288 return "", fmt.Errorf("unable to encode JSONValue, %v", err)
284 } 289 }
285 default: 290 default:
286 err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) 291 err := fmt.Errorf("unsupported value for param %v (%s)", v.Interface(), v.Type())
287 return "", err 292 return "", err
288 } 293 }
289 return str, nil 294 return str, nil
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go
index 7a779ee..33fd53b 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go
@@ -3,7 +3,6 @@ package rest
3import ( 3import (
4 "bytes" 4 "bytes"
5 "encoding/base64" 5 "encoding/base64"
6 "encoding/json"
7 "fmt" 6 "fmt"
8 "io" 7 "io"
9 "io/ioutil" 8 "io/ioutil"
@@ -16,6 +15,7 @@ import (
16 "github.com/aws/aws-sdk-go/aws" 15 "github.com/aws/aws-sdk-go/aws"
17 "github.com/aws/aws-sdk-go/aws/awserr" 16 "github.com/aws/aws-sdk-go/aws/awserr"
18 "github.com/aws/aws-sdk-go/aws/request" 17 "github.com/aws/aws-sdk-go/aws/request"
18 "github.com/aws/aws-sdk-go/private/protocol"
19) 19)
20 20
21// UnmarshalHandler is a named request handler for unmarshaling rest protocol requests 21// UnmarshalHandler is a named request handler for unmarshaling rest protocol requests
@@ -198,23 +198,21 @@ func unmarshalHeader(v reflect.Value, header string, tag reflect.StructTag) erro
198 } 198 }
199 v.Set(reflect.ValueOf(&f)) 199 v.Set(reflect.ValueOf(&f))
200 case *time.Time: 200 case *time.Time:
201 t, err := time.Parse(RFC822, header) 201 format := tag.Get("timestampFormat")
202 if len(format) == 0 {
203 format = protocol.RFC822TimeFormatName
204 }
205 t, err := protocol.ParseTime(format, header)
202 if err != nil { 206 if err != nil {
203 return err 207 return err
204 } 208 }
205 v.Set(reflect.ValueOf(&t)) 209 v.Set(reflect.ValueOf(&t))
206 case aws.JSONValue: 210 case aws.JSONValue:
207 b := []byte(header) 211 escaping := protocol.NoEscape
208 var err error
209 if tag.Get("location") == "header" { 212 if tag.Get("location") == "header" {
210 b, err = base64.StdEncoding.DecodeString(header) 213 escaping = protocol.Base64Escape
211 if err != nil {
212 return err
213 }
214 } 214 }
215 215 m, err := protocol.DecodeJSONValue(header, escaping)
216 m := aws.JSONValue{}
217 err = json.Unmarshal(b, &m)
218 if err != nil { 216 if err != nil {
219 return err 217 return err
220 } 218 }
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go
new file mode 100644
index 0000000..b7ed6c6
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go
@@ -0,0 +1,72 @@
1package protocol
2
3import (
4 "strconv"
5 "time"
6)
7
8// Names of time formats supported by the SDK
9const (
10 RFC822TimeFormatName = "rfc822"
11 ISO8601TimeFormatName = "iso8601"
12 UnixTimeFormatName = "unixTimestamp"
13)
14
15// Time formats supported by the SDK
16const (
17 // RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT
18 RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT"
19
20 // RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z
21 ISO8601TimeFormat = "2006-01-02T15:04:05Z"
22)
23
24// IsKnownTimestampFormat returns if the timestamp format name
25// is know to the SDK's protocols.
26func IsKnownTimestampFormat(name string) bool {
27 switch name {
28 case RFC822TimeFormatName:
29 fallthrough
30 case ISO8601TimeFormatName:
31 fallthrough
32 case UnixTimeFormatName:
33 return true
34 default:
35 return false
36 }
37}
38
39// FormatTime returns a string value of the time.
40func FormatTime(name string, t time.Time) string {
41 t = t.UTC()
42
43 switch name {
44 case RFC822TimeFormatName:
45 return t.Format(RFC822TimeFormat)
46 case ISO8601TimeFormatName:
47 return t.Format(ISO8601TimeFormat)
48 case UnixTimeFormatName:
49 return strconv.FormatInt(t.Unix(), 10)
50 default:
51 panic("unknown timestamp format name, " + name)
52 }
53}
54
55// ParseTime attempts to parse the time given the format. Returns
56// the time if it was able to be parsed, and fails otherwise.
57func ParseTime(formatName, value string) (time.Time, error) {
58 switch formatName {
59 case RFC822TimeFormatName:
60 return time.Parse(RFC822TimeFormat, value)
61 case ISO8601TimeFormatName:
62 return time.Parse(ISO8601TimeFormat, value)
63 case UnixTimeFormatName:
64 v, err := strconv.ParseFloat(value, 64)
65 if err != nil {
66 return time.Time{}, err
67 }
68 return time.Unix(int64(v), 0), nil
69 default:
70 panic("unknown timestamp format name, " + formatName)
71 }
72}
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
index 7091b45..07764c8 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
@@ -13,9 +13,13 @@ import (
13 "github.com/aws/aws-sdk-go/private/protocol" 13 "github.com/aws/aws-sdk-go/private/protocol"
14) 14)
15 15
16// BuildXML will serialize params into an xml.Encoder. 16// BuildXML will serialize params into an xml.Encoder. Error will be returned
17// Error will be returned if the serialization of any of the params or nested values fails. 17// if the serialization of any of the params or nested values fails.
18func BuildXML(params interface{}, e *xml.Encoder) error { 18func BuildXML(params interface{}, e *xml.Encoder) error {
19 return buildXML(params, e, false)
20}
21
22func buildXML(params interface{}, e *xml.Encoder, sorted bool) error {
19 b := xmlBuilder{encoder: e, namespaces: map[string]string{}} 23 b := xmlBuilder{encoder: e, namespaces: map[string]string{}}
20 root := NewXMLElement(xml.Name{}) 24 root := NewXMLElement(xml.Name{})
21 if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil { 25 if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil {
@@ -23,7 +27,7 @@ func BuildXML(params interface{}, e *xml.Encoder) error {
23 } 27 }
24 for _, c := range root.Children { 28 for _, c := range root.Children {
25 for _, v := range c { 29 for _, v := range c {
26 return StructToXML(e, v, false) 30 return StructToXML(e, v, sorted)
27 } 31 }
28 } 32 }
29 return nil 33 return nil
@@ -278,8 +282,12 @@ func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag refl
278 case float32: 282 case float32:
279 str = strconv.FormatFloat(float64(converted), 'f', -1, 32) 283 str = strconv.FormatFloat(float64(converted), 'f', -1, 32)
280 case time.Time: 284 case time.Time:
281 const ISO8601UTC = "2006-01-02T15:04:05Z" 285 format := tag.Get("timestampFormat")
282 str = converted.UTC().Format(ISO8601UTC) 286 if len(format) == 0 {
287 format = protocol.ISO8601TimeFormatName
288 }
289
290 str = protocol.FormatTime(format, converted)
283 default: 291 default:
284 return fmt.Errorf("unsupported value for param %s: %v (%s)", 292 return fmt.Errorf("unsupported value for param %s: %v (%s)",
285 tag.Get("locationName"), value.Interface(), value.Type().Name()) 293 tag.Get("locationName"), value.Interface(), value.Type().Name())
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go
index 8758462..ff1ef68 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go
@@ -9,6 +9,8 @@ import (
9 "strconv" 9 "strconv"
10 "strings" 10 "strings"
11 "time" 11 "time"
12
13 "github.com/aws/aws-sdk-go/private/protocol"
12) 14)
13 15
14// UnmarshalXML deserializes an xml.Decoder into the container v. V 16// UnmarshalXML deserializes an xml.Decoder into the container v. V
@@ -52,9 +54,15 @@ func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
52 if t == "" { 54 if t == "" {
53 switch rtype.Kind() { 55 switch rtype.Kind() {
54 case reflect.Struct: 56 case reflect.Struct:
55 t = "structure" 57 // also it can't be a time object
58 if _, ok := r.Interface().(*time.Time); !ok {
59 t = "structure"
60 }
56 case reflect.Slice: 61 case reflect.Slice:
57 t = "list" 62 // also it can't be a byte slice
63 if _, ok := r.Interface().([]byte); !ok {
64 t = "list"
65 }
58 case reflect.Map: 66 case reflect.Map:
59 t = "map" 67 t = "map"
60 } 68 }
@@ -247,8 +255,12 @@ func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
247 } 255 }
248 r.Set(reflect.ValueOf(&v)) 256 r.Set(reflect.ValueOf(&v))
249 case *time.Time: 257 case *time.Time:
250 const ISO8601UTC = "2006-01-02T15:04:05Z" 258 format := tag.Get("timestampFormat")
251 t, err := time.Parse(ISO8601UTC, node.Text) 259 if len(format) == 0 {
260 format = protocol.ISO8601TimeFormatName
261 }
262
263 t, err := protocol.ParseTime(format, node.Text)
252 if err != nil { 264 if err != nil {
253 return err 265 return err
254 } 266 }
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go
index 3e970b6..515ce15 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go
@@ -29,6 +29,7 @@ func NewXMLElement(name xml.Name) *XMLNode {
29 29
30// AddChild adds child to the XMLNode. 30// AddChild adds child to the XMLNode.
31func (n *XMLNode) AddChild(child *XMLNode) { 31func (n *XMLNode) AddChild(child *XMLNode) {
32 child.parent = n
32 if _, ok := n.Children[child.Name.Local]; !ok { 33 if _, ok := n.Children[child.Name.Local]; !ok {
33 n.Children[child.Name.Local] = []*XMLNode{} 34 n.Children[child.Name.Local] = []*XMLNode{}
34 } 35 }