2017-01-12 10:16:28 +00:00
|
|
|
// Package query provides serialization of AWS query requests, and responses.
|
2016-01-22 02:17:53 +00:00
|
|
|
package query
|
|
|
|
|
2020-03-09 07:09:54 +00:00
|
|
|
//go:generate go run -tags codegen ../../../private/model/cli/gen-protocol-tests ../../../models/protocol_tests/input/query.json build_test.go
|
2016-01-22 02:17:53 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
|
|
|
"github.com/aws/aws-sdk-go/aws/request"
|
|
|
|
"github.com/aws/aws-sdk-go/private/protocol/query/queryutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BuildHandler is a named request handler for building query protocol requests
|
|
|
|
var BuildHandler = request.NamedHandler{Name: "awssdk.query.Build", Fn: Build}
|
|
|
|
|
|
|
|
// Build builds a request for an AWS Query service.
|
|
|
|
func Build(r *request.Request) {
|
|
|
|
body := url.Values{
|
|
|
|
"Action": {r.Operation.Name},
|
|
|
|
"Version": {r.ClientInfo.APIVersion},
|
|
|
|
}
|
|
|
|
if err := queryutil.Parse(body, r.Params, false); err != nil {
|
2020-03-09 07:09:54 +00:00
|
|
|
r.Error = awserr.New(request.ErrCodeSerialization, "failed encoding Query request", err)
|
2016-01-22 02:17:53 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-08-14 19:13:40 +00:00
|
|
|
if !r.IsPresigned() {
|
2016-01-22 02:17:53 +00:00
|
|
|
r.HTTPRequest.Method = "POST"
|
|
|
|
r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
|
|
|
|
r.SetBufferBody([]byte(body.Encode()))
|
|
|
|
} else { // This is a pre-signed request
|
|
|
|
r.HTTPRequest.Method = "GET"
|
|
|
|
r.HTTPRequest.URL.RawQuery = body.Encode()
|
|
|
|
}
|
|
|
|
}
|