MCPcopy Create free account
hub / github.com/UiPath/uipathcli / writeBody

Method writeBody

executor/http_executor.go:236–261  ·  view source on GitHub ↗
(ctx ExecutionContext, cancel context.CancelCauseFunc)

Source from the content-addressed store, hash-verified

234}
235
236func (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
263func (e HttpExecutor) pathParameters(ctx ExecutionContext) []ExecutionParameter {
264 pathParameters := ctx.Parameters.Path()

Callers 1

CallMethod · 0.95

Calls 7

writeInputBodyMethod · 0.95
writeMultipartBodyMethod · 0.95
writeUrlEncodedBodyMethod · 0.95
writeJsonBodyMethod · 0.95
FormMethod · 0.80
BodyMethod · 0.80
SizeMethod · 0.65

Tested by

no test coverage detected