(ctx ExecutionContext, cancel context.CancelCauseFunc)
| 234 | } |
| 235 | |
| 236 | func (e HttpExecutor) writeBody(ctx ExecutionContext, cancel context.CancelCauseFunc) (io.ReadCloser, string, int64, int64) { |
| 237 | if ctx.Input != nil { |
| 238 | reader, writer := io.Pipe() |
| 239 | e.writeInputBody(writer, ctx.Input, cancel) |
| 240 | contentLength, _ := ctx.Input.Size() |
| 241 | return reader, ctx.ContentType, contentLength, contentLength |
| 242 | } |
| 243 | formParameters := ctx.Parameters.Form() |
| 244 | if len(formParameters) > 0 { |
| 245 | reader, writer := io.Pipe() |
| 246 | contentType, multipartSize := e.writeMultipartBody(writer, formParameters, cancel) |
| 247 | return reader, contentType, -1, multipartSize |
| 248 | } |
| 249 | bodyParameters := ctx.Parameters.Body() |
| 250 | if len(bodyParameters) > 0 && ctx.ContentType == "application/x-www-form-urlencoded" { |
| 251 | reader, writer := io.Pipe() |
| 252 | e.writeUrlEncodedBody(writer, bodyParameters, cancel) |
| 253 | return reader, ctx.ContentType, -1, -1 |
| 254 | } |
| 255 | if len(bodyParameters) > 0 { |
| 256 | reader, writer := io.Pipe() |
| 257 | e.writeJsonBody(writer, bodyParameters, cancel) |
| 258 | return reader, ctx.ContentType, -1, -1 |
| 259 | } |
| 260 | return io.NopCloser(bytes.NewReader([]byte{})), ctx.ContentType, -1, -1 |
| 261 | } |
| 262 | |
| 263 | func (e HttpExecutor) pathParameters(ctx ExecutionContext) []ExecutionParameter { |
| 264 | pathParameters := ctx.Parameters.Path() |
no test coverage detected