Git Product home page Git Product logo

Comments (7)

Samuel-Dufour avatar Samuel-Dufour commented on May 24, 2024 1

Hi,
I added a PR that should fix this issue.

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024

Thank you for the issue report. Unfortunately, I cannot reproduce it. If you have further info, please share them. In my test, I use VS2022, .Net SDK 6.0.304 and a plain .fsx file with the content copied from above.

Could you omit the |> Response.toText |> printfn "%s" and just run this in FSI:

#r "nuget: FsHttp"

open FsHttp

http {
    POST "https://api.jspm.io/generate"
    body
    json """
    {
        "install": [ "lodash" ],
        "env": [ "browser", "module" ],
        "graph":true,
        "provider": "jspm"
    }
    """
}
|> Request.send

This will print the request, and response + content in the FSI output - like this:

REQUEST
--------
POST https://api.jspm.io:443/generate HTTP/1.1
Cookie           : 
Content-Type     : application/json
Content-Length   : 108
===content===
{
    "install": [ "lodash" ],
    "env": [ "browser", "module" ],
    "graph":true,
    "provider": "jspm"}

RESPONSE
---------
HTTP/1.1 200 OK
Access-Control-Allow-Origin   : *
Transfer-Encoding             : chunked
Date                          : Mon, 03 Oct 2022 09:04:37 GMT
Server                        : Google, Frontend
Content-Type                  : application/json

===content===
{
  "staticDeps": [
    "https://ga.jspm.io/npm:[email protected]/lodash.js"
  ],
  "dynamicDeps": [],
  "map": {
    "imports": {
      "lodash": "https://ga.jspm.io/npm:[email protected]/lodash.js"
    }
  },
  "graph": {
    "https://ga.jspm.io/npm:[email protected]/": {
      "lodash.js": {}
    }
  }
}

from fshttp.

AngelMunoz avatar AngelMunoz commented on May 24, 2024

Ah yes, I forgot to include that I'm on .NET7 previews
here's the dotnet --info output

.NET SDK:
 Version:   7.0.100-rc.1.22431.12
 Commit:    f1cf61e1c0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\

Host:
  Version:      7.0.0-rc.1.22426.10
  Architecture: x64
  Commit:       06aceb7015

.NET SDKs installed:
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.201 [C:\Program Files\dotnet\sdk]
  6.0.202 [C:\Program Files\dotnet\sdk]
  6.0.203 [C:\Program Files\dotnet\sdk]
  6.0.304 [C:\Program Files\dotnet\sdk]
  6.0.401 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

I tried removing the other pipes as you suggested

PS C:\Users\scyth> dotnet fsi

Microsoft (R) F# Interactive version 12.0.5.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> #r "nuget: FsHttp"

open FsHttp

http {
    POST "https://api.jspm.io/generate"
    body
    json """
    {
        "install": [ "lodash" ],
        "env": [ "browser", "module" ],
        "graph":true,
        "provider": "jspm"
    }
    """
}
|> Request.send;;
[Loading C:\Users\scyth\.packagemanagement\nuget\Projects\21160--a3433b23-913b-47d0-b283-151d8b574fa8\Project.fsproj.fsx]
module FSI_0002.Project.fsproj

Binding session to 'C:/Users/scyth/.nuget/packages/fshttp/9.1.2/lib/net6.0/FsHttp.dll'...
System.FormatException: The format of value '' is invalid.
   at System.Net.Http.Headers.HttpHeaderParser.ParseValue(String value, Object storeValue, Int32& index)
   at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
   at System.Net.Http.Headers.HttpHeaders.Add(HeaderDescriptor descriptor, String value)
   at System.Net.Http.Headers.HttpHeaders.Add(String name, String value)
   at [email protected](CancellationToken ctok)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 528
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1140
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1167
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1511
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\scyth\stdin:line 6
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error
>

Using a global json with .NET6 seems to work though it might be something newly introduced in .NET7

PS C:\Users\scyth\repos\scripts> dotnet --version
6.0.304
PS C:\Users\scyth\repos\scripts> dotnet fsi

Microsoft (R) F# Interactive version 12.0.4.0 for F# 6.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> #r "nuget: FsHttp"
- 
- open FsHttp
- 
- http {
-     POST "https://api.jspm.io/generate"
-     body
-     json ("""{
-     "install": [ "lodash" ],
-     "env": [ "browser", "module" ],
-     "graph":true,
-     "provider": "jspm"}""")
- }
- |> Request.send;;
[Loading C:\Users\scyth\AppData\Local\Temp\17468--537756bf-cf9e-42c5-acab-1d32703715f9\Project.fsproj.fsx]
namespace FSI_0002.Project

Binding session to 'C:/Users/scyth/.nuget/packages/fshttp/9.1.2/lib/net6.0/FsHttp.dll'...
val it: FsHttp.Domain.Response =
  
REQUEST
--------
POST https://api.jspm.io:443/generate HTTP/1.1
Cookie           : 
Content-Type     : application/json
Content-Length   : 108
===content===
{
    "install": [ "lodash" ],
    "env": [ "browser", "module" ],
    "graph":true,
    "provider": "jspm"}

RESPONSE
---------
HTTP/1.1 200 OK
Access-Control-Allow-Origin   : *
Transfer-Encoding             : chunked
Date                          : Mon, 03 Oct 2022 12:27:04 GMT
Server                        : Google, Frontend
Content-Type                  : application/json

===content===
{
  "staticDeps": [
    "https://ga.jspm.io/npm:[email protected]/lodash.js"
  ],
  "dynamicDeps": [],
  "map": {
    "imports": {
      "lodash": "https://ga.jspm.io/npm:[email protected]/lodash.js"
    }
  },
  "graph": {
    "https://ga.jspm.io/npm:[email protected]/": {
      "lodash.js": {}
    }
  }
}
>

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024

Thanks for the info. I'll investigate and see if that might be a bug in .Net 7 or if FsHttp is doing something wrong that might have been masked before...

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024

Thanks for reporting the issue @AngelMunoz and fixing it @Samuel-Dufour :)

I've released and tested 10.0.0-preview2. See related PR and commits.

from fshttp.

OnurGumus avatar OnurGumus commented on May 24, 2024

Hah I also hit this one just now

from fshttp.

CaptnCodr avatar CaptnCodr commented on May 24, 2024

Yep, me too. 😄
This fix helped a lot!

from fshttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.