func()

in events/lambda_function_urls.go [96:122]


func (r *LambdaFunctionURLStreamingResponse) Read(p []byte) (n int, err error) {
	if r.prelude == nil {
		if r.StatusCode == 0 {
			r.StatusCode = http.StatusOK
		}
		b, err := json.Marshal(struct {
			StatusCode int               `json:"statusCode"`
			Headers    map[string]string `json:"headers,omitempty"`
			Cookies    []string          `json:"cookies,omitempty"`
		}{
			StatusCode: r.StatusCode,
			Headers:    r.Headers,
			Cookies:    r.Cookies,
		})
		if err != nil {
			return 0, err
		}
		r.prelude = bytes.NewBuffer(append(b, 0, 0, 0, 0, 0, 0, 0, 0))
	}
	if r.prelude.Len() > 0 {
		return r.prelude.Read(p)
	}
	if r.Body == nil {
		return 0, io.EOF
	}
	return r.Body.Read(p)
}