HaxeFoundation / hxcs

Haxe C# support library. Build scripts and support code.
The Unlicense
57 stars 21 forks source link

missing HttpClient #52

Open lublak opened 3 years ago

lublak commented 3 years ago

https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-5.0

I am currently trying to use the http client. Unfortunately it is not available in the haxe context.

Also as alternative: cs.system.net.WebRequest WebHeaderCollection is not avaible on net 50 only on 45

https://docs.microsoft.com/en-us/dotnet/api/system.net.httpwebresponse.headers?view=net-5.0#System_Net_HttpWebResponse_Headers

acarioni commented 2 years ago

Environment haxe 4.2.4 mono 6.12.0

I have the same problem. I have tried to leverage the --net-std option and to make it point to my mono installation /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.8-api (by the way, is it the right path? there is also /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.5 without the -api suffix, for example).

But when I try to compile even a simple program like the following

package foo;

class Main {
  static function main() {
    var client = new cs.system.net.http.HttpClient();
  }
}

I get the error

haxelib run hxcs hxcs_build.txt --haxe-version 4204 --feature-level 1 --out bin/cs/bin/Main
src/foo/Main.cs(27,28): error CS0234: The type or namespace name `HttpClient' does not exist in the namespace `System.Net.Http'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
Compilation error
Native compilation failed
Failed to invoke `haxelib run-dir hxcs "/Users/foobar/haxe/haxe_libraries/hxcs/4.2.0/github/9c463ff27236958fdb13eef1092e35eaecaab426" hxcs_build.txt --haxe-version 4204 --feature-level 1 --out bin/cs/bin/Main` because Error: Command failed: haxelib run-dir hxcs "/Users/foobar/haxe/haxe_libraries/hxcs/4.2.0/github/9c463ff27236958fdb13eef1092e35eaecaab426" hxcs_build.txt --haxe-version 4204 --feature-level 1 --out bin/cs/bin/Main
Error: Build failed

Any help would be greatly appreciated.