Fix incorrect merge resolution of Http module

This commit is contained in:
Richard Feldman 2022-07-21 10:24:37 -04:00 committed by Ayaz Hafiz
parent 7d1376b273
commit f3dfab8a94
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -13,9 +13,9 @@ interface Http
bytesBody, bytesBody,
stringBody, stringBody,
# jsonBody, # jsonBody,
multiPartBody, # multiPartBody,
stringPart, # stringPart,
bytesPart, # bytesPart,
handleStringResponse, handleStringResponse,
defaultRequest, defaultRequest,
errorToString, errorToString,
@ -27,8 +27,8 @@ interface Http
# Json, # Json,
Task.{ Task }, Task.{ Task },
# Encode.{ Encoding }, # Encode.{ Encoding },
HttpTypes.{ Request, Method, Header, Timeout, ProgressTracking, Part, Body, Response, Metadata, Error },
Url.{ Url }, Url.{ Url },
InternalHttp,
] ]
HttpErr a : [ HttpErr a : [
@ -78,28 +78,26 @@ stringBody = \mimeType, str ->
# jsonBody : a -> Body | a has Encoding # jsonBody : a -> Body | a has Encoding
# jsonBody = \val -> # jsonBody = \val ->
# Body (MimeType "application/json") (Encode.toBytes val Json.format) # Body (MimeType "application/json") (Encode.toBytes val Json.format)
multiPartBody : List Part -> Body #
multiPartBody = \parts -> # multiPartBody : List Part -> Body
boundary = "7MA4YWxkTrZu0gW" # TODO: what's this exactly? a hash of all the part bodies? # multiPartBody = \parts ->
beforeName = Str.toUtf8 "-- \(boundary)\r\nContent-Disposition: form-data; name=\"" # boundary = "7MA4YWxkTrZu0gW" # TODO: what's this exactly? a hash of all the part bodies?
afterName = Str.toUtf8 "\"\r\n" # beforeName = Str.toUtf8 "-- \(boundary)\r\nContent-Disposition: form-data; name=\""
appendPart = \buffer, Part name partBytes -> # afterName = Str.toUtf8 "\"\r\n"
buffer # appendPart = \buffer, Part name partBytes ->
|> List.concat beforeName # buffer
|> List.concat (Str.toUtf8 name) # |> List.concat beforeName
|> List.concat afterName # |> List.concat (Str.toUtf8 name)
|> List.concat partBytes # |> List.concat afterName
bodyBytes = List.walk parts [] appendPart # |> List.concat partBytes
# bodyBytes = List.walk parts [] appendPart
Body (MimeType "multipart/form-data;boundary=\"\(boundary)\"") bodyBytes # Body (MimeType "multipart/form-data;boundary=\"\(boundary)\"") bodyBytes
# bytesPart : Str, List U8 -> Part
bytesPart : Str, List U8 -> Part # bytesPart =
bytesPart = # Part
Part # stringPart : Str, Str -> Part
# stringPart = \name, str ->
stringPart : Str, Str -> Part # Part name (Str.toUtf8 str)
stringPart = \name, str ->
Part name (Str.toUtf8 str)
handleStringResponse : Response -> Result Str Error handleStringResponse : Response -> Result Str Error
handleStringResponse = \response -> handleStringResponse = \response ->