This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +1271
-453
lines changed Expand file tree Collapse file tree 9 files changed +1271
-453
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,12 @@ internal static partial class Interop
5
5
{
6
6
private static partial class Libraries
7
7
{
8
+ internal const string CryptoInterop = "System.Security.Cryptography.Native" ;
9
+ internal const string IOInterop = "System.IO.Native" ;
8
10
internal const string Libc = "libc" ; // C library
9
11
internal const string LibCoreClr = "libcoreclr" ; // CoreCLR runtime
10
12
internal const string LibCrypto = "libcrypto" ; // OpenSSL crypto library
13
+ internal const string LibCurl = "libcurl" ; // Curl HTTP client library
11
14
internal const string Zlib = "libz" ; // zlib compression library
12
- internal const string IOInterop = "System.IO.Native" ;
13
- internal const string CryptoInterop = "System.Security.Cryptography.Native" ;
14
15
}
15
16
}
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ using System ;
5
+ using System . Runtime . InteropServices ;
6
+
7
+ internal static partial class Interop
8
+ {
9
+ internal static partial class libcurl
10
+ {
11
+ internal sealed class SafeCurlHandle : SafeHandle
12
+ {
13
+ public SafeCurlHandle ( ) : base ( IntPtr . Zero , true )
14
+ {
15
+ }
16
+
17
+ public override bool IsInvalid
18
+ {
19
+ get { return this . handle == IntPtr . Zero ; }
20
+ }
21
+
22
+ public static void DisposeAndClearHandle ( ref SafeCurlHandle curlHandle )
23
+ {
24
+ if ( curlHandle != null )
25
+ {
26
+ curlHandle . Dispose ( ) ;
27
+ curlHandle = null ;
28
+ }
29
+ }
30
+
31
+ protected override bool ReleaseHandle ( )
32
+ {
33
+ Interop . libcurl . curl_easy_cleanup ( this . handle ) ;
34
+ return true ;
35
+ }
36
+ }
37
+ }
38
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ using System ;
5
+ using System . Runtime . InteropServices ;
6
+
7
+ internal static partial class Interop
8
+ {
9
+ internal static partial class libcurl
10
+ {
11
+ [ DllImport ( Interop . Libraries . LibCurl ) ]
12
+ public static extern SafeCurlHandle curl_easy_init ( ) ;
13
+
14
+ [ DllImport ( Interop . Libraries . LibCurl ) ]
15
+ public static extern void curl_easy_cleanup (
16
+ IntPtr handle ) ;
17
+
18
+ [ DllImport ( Interop . Libraries . LibCurl , CharSet = CharSet . Ansi ) ]
19
+ public static extern int curl_easy_setopt (
20
+ SafeCurlHandle curl ,
21
+ int option ,
22
+ string value ) ;
23
+
24
+ [ DllImport ( Interop . Libraries . LibCurl ) ]
25
+ public static extern int curl_easy_setopt (
26
+ SafeCurlHandle curl ,
27
+ int option ,
28
+ long value ) ;
29
+
30
+ [ DllImport ( Interop . Libraries . LibCurl ) ]
31
+ public static extern int curl_easy_perform (
32
+ SafeCurlHandle curl ) ;
33
+
34
+ [ DllImport ( Interop . Libraries . LibCurl ) ]
35
+ public static extern IntPtr curl_easy_strerror (
36
+ int code ) ;
37
+
38
+ [ DllImport ( Interop . Libraries . LibCurl ) ]
39
+ public static extern int curl_easy_getinfo (
40
+ SafeCurlHandle curl ,
41
+ int info ,
42
+ ref long value ) ; // Using a ref because it won't be populated on error
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ internal static partial class Interop
5
+ {
6
+ internal static partial class libcurl
7
+ {
8
+ // Class for constants defined for the enum CURLoption in curl.h
9
+ internal static partial class CURLoption
10
+ {
11
+ // Curl options are of the format <type base> + <n>
12
+ private const int CurlOptionLongBase = 0 ;
13
+ private const int CurlOptionObjectPointBase = 10000 ;
14
+
15
+ internal const int CURLOPT_FOLLOWLOCATION = CurlOptionLongBase + 52 ;
16
+ internal const int CURLOPT_URL = CurlOptionObjectPointBase + 2 ;
17
+ }
18
+
19
+ // Class for constants defined for the enum CURLINFO in curl.h
20
+ internal static partial class CURLINFO
21
+ {
22
+ // Curl info are of the format <type base> + <n>
23
+ private const int CurlInfoLongBase = 0x200000 ;
24
+ internal const int CURLINFO_RESPONSE_CODE = CurlInfoLongBase + 2 ;
25
+ }
26
+
27
+ // Class for constants defined for the enum CURLcode in curl.h
28
+ internal static partial class CURLcode
29
+ {
30
+ internal const int CURLE_OK = 0 ;
31
+ }
32
+ }
33
+ }
Original file line number Diff line number Diff line change 133
133
</ItemGroup >
134
134
135
135
<ItemGroup Condition =" '$(TargetsUnix)' == 'true' " >
136
- <Compile Include =" System\Net\Http\HttpClientHandler.Unix.cs" />
136
+ <Compile Include =" System\Net\Http\Unix\CurlHandler.cs" />
137
+ <Compile Include =" System\Net\Http\Unix\HttpClientHandler.Unix.cs" />
138
+ <Compile Include =" $(CommonPath)\Interop\Unix\Interop.Libraries.cs" >
139
+ <Link >Common\Interop\Unix\Interop.Libraries.cs</Link >
140
+ </Compile >
141
+ <Compile Include =" $(CommonPath)\Interop\Unix\libcurl\Interop.libcurl.cs" >
142
+ <Link >Common\Interop\Unix\libcurl\Interop.libcurl.cs</Link >
143
+ </Compile >
144
+ <Compile Include =" $(CommonPath)\Interop\Unix\libcurl\Interop.libcurl_types.cs" >
145
+ <Link >Common\Interop\Unix\libcurl\Interop.libcurl_types.cs</Link >
146
+ </Compile >
147
+ <Compile Include =" $(CommonPath)\Interop\Unix\libcurl\Interop.SafeCurlHandle.cs" >
148
+ <Link >Common\Interop\Unix\libcurl\Interop.SafeCurlHandle.cs</Link >
149
+ </Compile >
137
150
<Compile Include =" $(CommonPath)\System\NotImplemented.cs" >
138
151
<Link >Common\System\NotImplemented.cs</Link >
139
152
</Compile >
You can’t perform that action at this time.
0 commit comments