mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
Fix incorrect merge resolution of Http module
This commit is contained in:
parent
7d1376b273
commit
f3dfab8a94
1 changed files with 24 additions and 26 deletions
|
@ -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 ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue