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