MCPcopy Index your code
hub / github.com/aws/aws-lambda-go / sendWith

Method sendWith

cfn/response.go:53–83  ·  view source on GitHub ↗
(client httpClient)

Source from the content-addressed store, hash-verified

51}
52
53func (r *Response) sendWith(client httpClient) error {
54 body, err := json.Marshal(r)
55 if err != nil {
56 return err
57 }
58
59 req, err := http.NewRequest(http.MethodPut, r.url, bytes.NewBuffer(body))
60 if err != nil {
61 return err
62 }
63 req.Header.Del("Content-Type")
64
65 res, err := client.Do(req)
66 if err != nil {
67 return err
68 }
69
70 body, err = ioutil.ReadAll(res.Body)
71 if err != nil {
72 return err
73 }
74 res.Body.Close()
75
76 if res.StatusCode != 200 {
77 log.Printf("StatusCode: %d\nBody: %v\n", res.StatusCode, string(body))
78 return fmt.Errorf("invalid status code. got: %d", res.StatusCode)
79 }
80
81 return nil
82
83}
84
85// Send will send the Response to the given URL using the
86// default HTTP client

Callers 4

lambdaWrapWithClientFunction · 0.95
TestRequestSentCorrectlyFunction · 0.95
TestRequestForbiddenFunction · 0.95
SendMethod · 0.95

Calls 2

DoMethod · 0.65
CloseMethod · 0.45

Tested by 2

TestRequestSentCorrectlyFunction · 0.76
TestRequestForbiddenFunction · 0.76