Created
July 7, 2022 14:45
-
-
Save yodiz/6c7631ffc897a455185eb401e5fe62be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let private mapRequest (context : Microsoft.AspNetCore.Http.HttpContext) : Svea.Dry.Http.HttpRequest = | |
if context.Request.HasFormContentType then | |
let newStream : System.IO.Stream = | |
let ms = new System.IO.MemoryStream() | |
use sw = new System.IO.StreamWriter(ms, System.Text.Encoding.UTF8, 4096, true) | |
let mutable isFirst = true | |
for item in context.Request.Form do | |
sw.Write(sprintf "%s=%s" (System.Web.HttpUtility.UrlEncode(item.Key)) (item.Value |> Seq.map (fun x -> System.Web.HttpUtility.UrlEncode(x)) |> String.concat ",")) | |
if isFirst then | |
isFirst <- false | |
sw.Write("&") | |
sw.Flush() | |
ms.Seek(0L, System.IO.SeekOrigin.Begin) |> ignore | |
ms | |
context.Request.Body <- newStream |
Så korkad jag är, tänkte fel med &:andeet :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Det verkar som att den bara klarar av 1-2 parametrar p.g.a "isFirst". Övriga parametrar kommer att tappa sin skiljare "&". Här är möjligtvis en bättre lösning: