diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go | 33 |
1 files changed, 19 insertions, 14 deletions
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 | |||
4 | import ( | 4 | import ( |
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 | ||
24 | const 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 |
27 | var noEscape [256]bool | 24 | var 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 | ||
255 | func convertType(v reflect.Value, tag reflect.StructTag) (string, error) { | 252 | func 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 |