These are chat archives for freya-fs/arachne

Oct 2015
How's that?
Ryan Riley
Oct 23 2015 16:01
Now for some tasty cookies ... ;)
@kolektiv, I'm interested in your opinion, btw, on which lib I should pull into my fork of WebSharper.Owin. I'm trying to replace Microsoft.Owin with raw OWIN, but I think using Arachne and/or Freya would be helpful. I'm currently leaning away from Freya b/c it introduces async, etc., where WebSharper does not. See
Main diff is here: panesofglass/websharper.owin@1d2b448
Ryan Riley
Oct 23 2015 16:08
I'm currently blocked by Cookie- and querystring-related types from Microsoft.Owin: RequestCookieCollection, ctx.Request.Cookies, and ctx.Response.Cookies.
I'm nearly there with query strings. I just need to convert a query string into an seq<KeyValuePair<string, string[]>>.
I had thought to pull in Arachne, but I'm not even sure that's really necessary.
Lastly, do we have lenses for the equivalent of these functions in Arachne or Freya?
// TODO: Use Arachne or Freya.Core instead.
module Environment =
    let getHost (env : Env) =
        let headers : HeaderDictionary = unbox env.["owin.RequestHeaders"]
        let host =
            if headers.ContainsKey("Host") then
                unbox headers.["Host"].[0]
            else ""
        match host with
        | null | "" ->
            let localIpAddress =
                if env.ContainsKey("server.LocalIpAddress") then
                    match unbox env.["server.LocalIpAddress"] with
                    | null | "" -> "localhost"
                    | localIp -> localIp
                else "localhost"
            let localPort =
                if env.ContainsKey("server.LocalPort") then
                    unbox env.["server.LocalPort"]
                else ""
            if String.IsNullOrWhiteSpace localPort then localIpAddress else localIpAddress + ":" + localPort
        | _ -> host

    let getBaseUri (env : Env) =
        unbox env.["owin.RequestScheme"] + "://" +
        getHost env +
        if String.IsNullOrEmpty (unbox env.["owin.RequestPathBase"]) then "/" else unbox env.["owin.RequestPathBase"]

    let getRequestUri (env : Env) =
        unbox env.["owin.RequestScheme"] + "://" +
        getHost env +
        (unbox env.["owin.RequestPathBase"]) +
        (unbox env.["owin.RequestPath"]) +
        if String.IsNullOrEmpty (unbox env.["owin.RequestQueryString"]) then "" else "?" + (unbox env.["owin.RequestQueryString"])
Those are not strictly HTTP-related, so I don't think they belong in Arachne.
Andrew Cherry
Oct 23 2015 22:41
we have parts, things like the headers collection, but that's in freya. you could write a lens fairly easily from owin to the arachne types though (it would be basically what is currently Freya.Lenses.Http)
query string related bits should be available as part of the Arachne.Uri world I think...
and cookies are not far from done either - i think! ( for latest)
the difficult bit potentially is a good answer around how owin specifies multiple header instances, the spec is really loose which might be fun.
haven't properly tackled that in freya yet either, as it's usually an edge case, but cookies are the first place where it probably really isn't...
it may turn out to be very simple, but i'm not sure yet! i remember katana at least doing some odd things
looking at that code, about the only bit which i would imagine us not to have in some reasonable way (although possibly with freya providing the lens bridge from owin to arachne) is the bits in the server.* keyspace, which I haven't really looked at