passagemath-gap-pkg-curlinterface 10.6.34__cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gap/pkg/curlinterface/CHANGES +79 -0
- gap/pkg/curlinterface/GPL +339 -0
- gap/pkg/curlinterface/LICENSE +16 -0
- gap/pkg/curlinterface/PackageInfo.g +144 -0
- gap/pkg/curlinterface/README.md +8 -0
- gap/pkg/curlinterface/bin/aarch64-unknown-linux-gnu-default64-kv10/curl.so +0 -0
- gap/pkg/curlinterface/gap/curl.gd +169 -0
- gap/pkg/curlinterface/gap/curl.gi +67 -0
- gap/pkg/curlinterface/init.g +15 -0
- gap/pkg/curlinterface/makedoc.g +10 -0
- gap/pkg/curlinterface/read.g +6 -0
- gap/pkg/curlinterface/tst/basic.tst +198 -0
- gap/pkg/curlinterface/tst/errors.tst +65 -0
- gap/pkg/curlinterface/tst/testall.g +12 -0
- passagemath_gap_pkg_curlinterface-10.6.34.dist-info/METADATA +93 -0
- passagemath_gap_pkg_curlinterface-10.6.34.dist-info/METADATA.bak +94 -0
- passagemath_gap_pkg_curlinterface-10.6.34.dist-info/RECORD +25 -0
- passagemath_gap_pkg_curlinterface-10.6.34.dist-info/WHEEL +6 -0
- passagemath_gap_pkg_curlinterface-10.6.34.dist-info/top_level.txt +1 -0
- passagemath_gap_pkg_curlinterface.libs/libcrypto-625d2422.so.3 +0 -0
- passagemath_gap_pkg_curlinterface.libs/libcurl-ef5189c4.so.4.8.0 +0 -0
- passagemath_gap_pkg_curlinterface.libs/libssl-dac2f451.so.3 +0 -0
- sage/all__sagemath_gap_pkg_curlinterface.py +1 -0
- sage/libs/all__sagemath_gap_pkg_curlinterface.py +1 -0
- sage/libs/gap_pkg_curlinterface.cpython-314t-aarch64-linux-gnu.so +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#
|
|
2
|
+
# curlInterface: Simple Web Access
|
|
3
|
+
#
|
|
4
|
+
#! @Chapter Overview
|
|
5
|
+
#!
|
|
6
|
+
#! CurlInterface allows a user to interact with http and https
|
|
7
|
+
#! servers on the internet, using the 'curl' library.
|
|
8
|
+
#! Pages can be downloaded from a URL, and http POST requests
|
|
9
|
+
#! can be sent to the URL for processing.
|
|
10
|
+
|
|
11
|
+
#! @Section Installing curlInterface
|
|
12
|
+
#!
|
|
13
|
+
#! curlInterface requires the 'curl' library, available from
|
|
14
|
+
#! <URL>https://curl.haxx.se/</URL>. Instructions for building
|
|
15
|
+
#! and installing curl can be found at
|
|
16
|
+
#! <URL>https://curl.haxx.se/docs/install.html</URL>, however
|
|
17
|
+
#! in most systems curl can be installed from your OS's package
|
|
18
|
+
#! manager.
|
|
19
|
+
#!
|
|
20
|
+
#! @Subsection Linux
|
|
21
|
+
#!
|
|
22
|
+
#! <List>
|
|
23
|
+
#! <Item>
|
|
24
|
+
#! On Debian and Ubuntu, call: <C>apt-get install libcurl4-gnutls-dev</C></Item>
|
|
25
|
+
#! <Item>
|
|
26
|
+
#! On Redhat and derivatives, call: <C>yum install curl-devel</C></Item>
|
|
27
|
+
#! </List>
|
|
28
|
+
#!
|
|
29
|
+
#! @Subsection Cygwin
|
|
30
|
+
#!
|
|
31
|
+
#! Install <C>libcurl-devel</C> from the cygwin package manager
|
|
32
|
+
#!
|
|
33
|
+
#! @Subsection macOS
|
|
34
|
+
#!
|
|
35
|
+
#! curl is installed by default on Macs, but libcurl may be required.
|
|
36
|
+
#! <List>
|
|
37
|
+
#! <Item>Homebrew: <C>brew install curl</C></Item>
|
|
38
|
+
#! <Item>Fink: <C>fink install libcurl4</C></Item>
|
|
39
|
+
#! <Item>MacPorts: <C>port install curl</C></Item>
|
|
40
|
+
#! </List>
|
|
41
|
+
|
|
42
|
+
#! @Section Functions
|
|
43
|
+
#!
|
|
44
|
+
#! curlInterface currently provides the following functions for interacting with
|
|
45
|
+
#! URLs:
|
|
46
|
+
|
|
47
|
+
#! @Arguments URL[, opts]
|
|
48
|
+
#! @Returns
|
|
49
|
+
#! a record
|
|
50
|
+
#! @Description
|
|
51
|
+
#! Downloads a URL from the internet. <A>URL</A> should be a string
|
|
52
|
+
#! describing the address, and should start with either "http://" or
|
|
53
|
+
#! "https://".
|
|
54
|
+
#! For descriptions of the output and the additional argument <A>opts</A>, see
|
|
55
|
+
#! <Ref Func="CurlRequest"/>.
|
|
56
|
+
#!
|
|
57
|
+
#! @BeginExample
|
|
58
|
+
#! gap> r := DownloadURL("www.gap-system.org");;
|
|
59
|
+
#! gap> r.success;
|
|
60
|
+
#! true
|
|
61
|
+
#! gap> r.result{[1..50]};
|
|
62
|
+
#! "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!DOCTYPE "
|
|
63
|
+
#! @EndExample
|
|
64
|
+
DeclareGlobalFunction("DownloadURL");
|
|
65
|
+
|
|
66
|
+
#! @Arguments URL, str[, opts]
|
|
67
|
+
#! @Returns
|
|
68
|
+
#! a record
|
|
69
|
+
#! @Description
|
|
70
|
+
#! Sends an HTTP POST request to a URL on the internet. <A>URL</A> should be a
|
|
71
|
+
#! string describing the address, and should start with either "http://" or
|
|
72
|
+
#! "https://". <A>str</A> should be the string which will be sent to the
|
|
73
|
+
#! server as a POST request.
|
|
74
|
+
#! For descriptions of the output and the additional argument <A>opts</A>, see
|
|
75
|
+
#! <Ref Func="CurlRequest"/>.
|
|
76
|
+
#!
|
|
77
|
+
#! @BeginExample
|
|
78
|
+
#! gap> r := PostToURL("httpbun.com/post", "animal=tiger");;
|
|
79
|
+
#! gap> r.success;
|
|
80
|
+
#! true
|
|
81
|
+
#! gap> r.result{[51..100]};
|
|
82
|
+
#! "\"form\": {\n \"animal\": \"tiger\"\n }, \n \"headers\":"
|
|
83
|
+
#! @EndExample
|
|
84
|
+
DeclareGlobalFunction("PostToURL");
|
|
85
|
+
|
|
86
|
+
#! @Arguments URL[, opts]
|
|
87
|
+
#! @Returns
|
|
88
|
+
#! a record
|
|
89
|
+
#! @Description
|
|
90
|
+
#! Attempts to delete a file on the internet, by sending an HTTP DELETE
|
|
91
|
+
#! request to the given URL. <A>URL</A> should be a string describing the
|
|
92
|
+
#! address to be deleted, and should start with either "http://" or
|
|
93
|
+
#! "https://".
|
|
94
|
+
#! For descriptions of the output and the additional argument <A>opts</A>, see
|
|
95
|
+
#! <Ref Func="CurlRequest"/>.
|
|
96
|
+
#!
|
|
97
|
+
#! @BeginExample
|
|
98
|
+
#! gap> r := DeleteURL("www.google.com");;
|
|
99
|
+
#! gap> r.success;
|
|
100
|
+
#! true
|
|
101
|
+
#! gap> r.result{[1471..1540]};
|
|
102
|
+
#! "<p>The request method <code>DELETE</code> is inappropriate for the URL"
|
|
103
|
+
#! @EndExample
|
|
104
|
+
DeclareGlobalFunction("DeleteURL");
|
|
105
|
+
|
|
106
|
+
#! @Arguments URL, type, out_string[, opts]
|
|
107
|
+
#! @Returns
|
|
108
|
+
#! a record
|
|
109
|
+
#! @Description
|
|
110
|
+
#! Sends an HTTP request of type <A>type</A> to a URL on the internet.
|
|
111
|
+
#! <A>URL</A>, <A>type</A>, and <A>out_string</A> should all be strings:
|
|
112
|
+
#! <A>URL</A> is the URL of the server (which should start with "http://" or
|
|
113
|
+
#! "https://"), <A>type</A> is the type of HTTP request (e.g. "GET"), and
|
|
114
|
+
#! <A>out_string</A> is the message, if any, to send to the server (in
|
|
115
|
+
#! requests such as GET this will be ignored).
|
|
116
|
+
#!
|
|
117
|
+
#! An optional fourth argument <A>opts</A> may be included, which should be a
|
|
118
|
+
#! record specifying additional options for the request. The following
|
|
119
|
+
#! options are supported:
|
|
120
|
+
#! * <C>verifyCert</C>: a boolean describing whether to verify HTTPS
|
|
121
|
+
#! certificates
|
|
122
|
+
#! (corresponds to the curl options <C>CURLOPT_SSL_VERIFYPEER</C>
|
|
123
|
+
#! and <C>CURLOPT_SSL_VERIFYHOST</C>,
|
|
124
|
+
#! the default is <K>true</K> for both);
|
|
125
|
+
#! * <C>verbose</C>: a boolean describing whether to print extra information
|
|
126
|
+
#! to the screen
|
|
127
|
+
#! (corresponds to the curl option <C>CURLOPT_VERBOSE</C>,
|
|
128
|
+
#! the default is <K>false</K>);
|
|
129
|
+
#! * <C>followRedirect</C>: a boolean describing whether to follow
|
|
130
|
+
#! redirection to another URL
|
|
131
|
+
#! (corresponds to the curl option <C>CURLOPT_FOLLOWLOCATION</C>,
|
|
132
|
+
#! the default is <K>true</K>);
|
|
133
|
+
#! * <C>failOnError</C>: a boolean describing whether to regard
|
|
134
|
+
#! 404 (and other 4xx) status codes as error
|
|
135
|
+
#! (corresponds to the curl option <C>CURLOPT_FAILONERROR</C>,
|
|
136
|
+
#! the default is <K>false</K>).
|
|
137
|
+
#! * <C>maxTime</C>: Maximum time in seconds that you allow each transfer
|
|
138
|
+
#! to take. 0 means no limitation. (default <K>0</K>).
|
|
139
|
+
#!
|
|
140
|
+
#! As output, this function returns a record containing some of the following
|
|
141
|
+
#! components, which describe the outcome of the request:
|
|
142
|
+
#! * <C>success</C>: a boolean describing whether the request was
|
|
143
|
+
#! successfully received by the server;
|
|
144
|
+
#! * <C>result</C>: body of the information sent by the server (only if
|
|
145
|
+
#! <C>success = true</C>);
|
|
146
|
+
#! * <C>error</C>: human-readable string saying what went wrong (only if
|
|
147
|
+
#! <C>success = false</C>).
|
|
148
|
+
#!
|
|
149
|
+
#! Most of the standard HTTP request types should work, but currently only
|
|
150
|
+
#! body information is returned. To see headers, consider using the
|
|
151
|
+
#! <C>verbose</C> option. For convenience, dedicated functions exist for the
|
|
152
|
+
#! following request types:
|
|
153
|
+
#! * <Ref Func="DownloadURL"/> for GET requests;
|
|
154
|
+
#! * <Ref Func="PostToURL"/> for POST requests;
|
|
155
|
+
#! * <Ref Func="DeleteURL"/> for DELETE requests.
|
|
156
|
+
#!
|
|
157
|
+
#! @BeginExample
|
|
158
|
+
#! gap> r := CurlRequest("https://www.google.com",
|
|
159
|
+
#! > "HEAD",
|
|
160
|
+
#! > "",
|
|
161
|
+
#! > rec(verifyCert := false));
|
|
162
|
+
#! rec( result := "", success := true )
|
|
163
|
+
#! gap> r := CurlRequest("httpbun.com/post", "POST", "animal=tiger");;
|
|
164
|
+
#! gap> r.success;
|
|
165
|
+
#! true
|
|
166
|
+
#! gap> r.result{[51..100]};
|
|
167
|
+
#! "\"form\": {\n \"animal\": \"tiger\"\n }, \n \"headers\":"
|
|
168
|
+
#! @EndExample
|
|
169
|
+
DeclareGlobalFunction("CurlRequest");
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#
|
|
2
|
+
# curlInterface: Simple Web Access
|
|
3
|
+
#
|
|
4
|
+
# Implementations
|
|
5
|
+
#
|
|
6
|
+
InstallGlobalFunction("CurlRequest",
|
|
7
|
+
function(URL, type, out_string, opts...)
|
|
8
|
+
local r, rnam;
|
|
9
|
+
|
|
10
|
+
# Get options
|
|
11
|
+
r := rec(verifyCert := true, verbose := false, followRedirect := true,
|
|
12
|
+
failOnError:= false, maxTime := 0);
|
|
13
|
+
if Length(opts) = 1 then
|
|
14
|
+
if not IsRecord(opts[1]) then
|
|
15
|
+
ErrorNoReturn("CurlRequest: <opts> must be a record");
|
|
16
|
+
fi;
|
|
17
|
+
for rnam in RecNames(opts[1]) do
|
|
18
|
+
r.(rnam) := opts[1].(rnam);
|
|
19
|
+
od;
|
|
20
|
+
elif Length(opts) > 1 then
|
|
21
|
+
ErrorNoReturn("CurlRequest: usage: requires 3 or 4 arguments, but ",
|
|
22
|
+
Length(opts) + 3, " were given");
|
|
23
|
+
fi;
|
|
24
|
+
|
|
25
|
+
# Check input
|
|
26
|
+
if not IsString(URL) then
|
|
27
|
+
ErrorNoReturn("CurlRequest: <URL> must be a string");
|
|
28
|
+
elif not IsString(type) then
|
|
29
|
+
ErrorNoReturn("CurlRequest: <type> must be a string");
|
|
30
|
+
elif not IsString(out_string) then
|
|
31
|
+
ErrorNoReturn("CurlRequest: <out_string> must be a string");
|
|
32
|
+
fi;
|
|
33
|
+
for rnam in ["verifyCert", "verbose", "followRedirect", "failOnError"] do
|
|
34
|
+
if r.(rnam) <> true and r.(rnam) <> false then
|
|
35
|
+
ErrorNoReturn("CurlRequest: <opts>.", rnam,
|
|
36
|
+
" must be true or false");
|
|
37
|
+
fi;
|
|
38
|
+
od;
|
|
39
|
+
for rnam in ["maxTime"] do
|
|
40
|
+
if r.(rnam) <> 0 and not IsPosInt(r.(rnam)) then
|
|
41
|
+
ErrorNoReturn("CurlRequest: <opts>.", rnam,
|
|
42
|
+
" must be a non-negative integer");
|
|
43
|
+
fi;
|
|
44
|
+
od;
|
|
45
|
+
|
|
46
|
+
return CURL_REQUEST(URL, type, out_string,
|
|
47
|
+
r.verifyCert,
|
|
48
|
+
r.verbose,
|
|
49
|
+
r.followRedirect,
|
|
50
|
+
r.failOnError,
|
|
51
|
+
r.maxTime);
|
|
52
|
+
end);
|
|
53
|
+
|
|
54
|
+
InstallGlobalFunction("DownloadURL",
|
|
55
|
+
function(URL, opts...)
|
|
56
|
+
return CallFuncList(CurlRequest, Concatenation([URL, "GET", ""], opts));
|
|
57
|
+
end);
|
|
58
|
+
|
|
59
|
+
InstallGlobalFunction("PostToURL",
|
|
60
|
+
function(URL, str, opts...)
|
|
61
|
+
return CallFuncList(CurlRequest, Concatenation([URL, "POST", str], opts));
|
|
62
|
+
end);
|
|
63
|
+
|
|
64
|
+
InstallGlobalFunction("DeleteURL",
|
|
65
|
+
function(URL, opts...)
|
|
66
|
+
return CallFuncList(CurlRequest, Concatenation([URL, "DELETE", ""], opts));
|
|
67
|
+
end);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#
|
|
2
|
+
# curlInterface: Simple Web Access
|
|
3
|
+
#
|
|
4
|
+
# Reading the declaration part of the package.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
if not LoadKernelExtension("curlInterface", "curl") then
|
|
8
|
+
Error("failed to load the curlInterface package kernel extension");
|
|
9
|
+
fi;
|
|
10
|
+
|
|
11
|
+
# work around a bug in some PackageManager versions, see
|
|
12
|
+
# <https://github.com/gap-packages/PackageManager/pull/100>.
|
|
13
|
+
Unbind(DownloadURL);
|
|
14
|
+
|
|
15
|
+
ReadPackage( "curlInterface", "gap/curl.gd");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#
|
|
2
|
+
# curlInterface: Simple Web Access
|
|
3
|
+
#
|
|
4
|
+
# This file is a script which compiles the package manual.
|
|
5
|
+
#
|
|
6
|
+
if fail = LoadPackage("AutoDoc", "2016.02.16") then
|
|
7
|
+
Error("AutoDoc version 2016.02.16 or newer is required.");
|
|
8
|
+
fi;
|
|
9
|
+
|
|
10
|
+
AutoDoc( rec( scaffold := true, autodoc := true ) );
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
gap> LoadPackage("curlInterface", false);
|
|
2
|
+
true
|
|
3
|
+
|
|
4
|
+
# Check HTTP
|
|
5
|
+
gap> r := DownloadURL("http://www.google.com");;
|
|
6
|
+
gap> SortedList(RecNames(r));
|
|
7
|
+
[ "result", "success" ]
|
|
8
|
+
gap> r.success;
|
|
9
|
+
true
|
|
10
|
+
gap> PositionSublist(r.result, "google") <> fail;
|
|
11
|
+
true
|
|
12
|
+
gap> PositionSublist("google", r.result) <> fail;
|
|
13
|
+
false
|
|
14
|
+
|
|
15
|
+
# Sanity check the result without actually printing it
|
|
16
|
+
gap> PositionSublist(r.result, "google") <> fail;
|
|
17
|
+
true
|
|
18
|
+
gap> r.result[1];
|
|
19
|
+
'<'
|
|
20
|
+
|
|
21
|
+
# Check HTTPS
|
|
22
|
+
gap> r := DownloadURL("https://www.google.com");;
|
|
23
|
+
gap> SortedList(RecNames(r));
|
|
24
|
+
[ "result", "success" ]
|
|
25
|
+
gap> r.success;
|
|
26
|
+
true
|
|
27
|
+
gap> PositionSublist(r.result, "google") <> fail;
|
|
28
|
+
true
|
|
29
|
+
gap> PositionSublist("google", r.result) <> fail;
|
|
30
|
+
false
|
|
31
|
+
|
|
32
|
+
# Sanity check the result without actually printing it
|
|
33
|
+
gap> PositionSublist(r.result, "google") <> fail;
|
|
34
|
+
true
|
|
35
|
+
gap> r.result[1];
|
|
36
|
+
'<'
|
|
37
|
+
|
|
38
|
+
# Check FTP
|
|
39
|
+
# Removed since we do not officially support FTP and it may fail in Docker
|
|
40
|
+
#gap> r := DownloadURL("ftp://fra36-speedtest-1.tele2.net/1KB.zip");;
|
|
41
|
+
#gap> SortedList(RecNames(r));
|
|
42
|
+
#[ "result", "success" ]
|
|
43
|
+
#gap> r.success;
|
|
44
|
+
#true
|
|
45
|
+
#gap> r.result = ListWithIdenticalEntries(1024, '\000');
|
|
46
|
+
#true
|
|
47
|
+
|
|
48
|
+
# Check bad URL
|
|
49
|
+
gap> r := DownloadURL("https://www.google.cheesebadger");;
|
|
50
|
+
gap> SortedList(RecNames(r));
|
|
51
|
+
[ "error", "success" ]
|
|
52
|
+
gap> r.success;
|
|
53
|
+
false
|
|
54
|
+
gap> PositionSublist(r.error, "Could not resolve host") <> fail;
|
|
55
|
+
true
|
|
56
|
+
|
|
57
|
+
# Check another bad URL
|
|
58
|
+
gap> r := DownloadURL("https://www.gap-system.org/Packages/curlInterface.x");;
|
|
59
|
+
gap> r.success;
|
|
60
|
+
true
|
|
61
|
+
gap> PositionSublist(r.result, "URL was not found") <> fail;
|
|
62
|
+
true
|
|
63
|
+
gap> r := DownloadURL("https://www.gap-system.org/Packages/curlInterface.x",
|
|
64
|
+
> rec(failOnError:= true));;
|
|
65
|
+
gap> r.success;
|
|
66
|
+
false
|
|
67
|
+
gap> PositionSublist(r.error, "404") <> fail;
|
|
68
|
+
true
|
|
69
|
+
|
|
70
|
+
# Check successful POST requests
|
|
71
|
+
gap> r := PostToURL("httpbun.com/post", "field1=true&field2=17");;
|
|
72
|
+
gap> SortedList(RecNames(r));
|
|
73
|
+
[ "result", "success" ]
|
|
74
|
+
gap> r.success;
|
|
75
|
+
true
|
|
76
|
+
gap> PositionSublist(r.result, "\"field1\": \"true\"") <> fail;
|
|
77
|
+
true
|
|
78
|
+
gap> PositionSublist(r.result, "\"field2\": \"17\"") <> fail;
|
|
79
|
+
true
|
|
80
|
+
gap> PositionSublist(r.result, "field3") <> fail;
|
|
81
|
+
false
|
|
82
|
+
|
|
83
|
+
# Check POST on a string with null characters
|
|
84
|
+
gap> r := PostToURL("httpbun.com/post", "field1=my\000first\000field");;
|
|
85
|
+
gap> SortedList(RecNames(r));
|
|
86
|
+
[ "result", "success" ]
|
|
87
|
+
gap> r.success;
|
|
88
|
+
true
|
|
89
|
+
gap> PositionSublist(r.result, "my\\u0000first\\u0000field") <> fail;
|
|
90
|
+
true
|
|
91
|
+
gap> PositionSublist(r.result, "field3") <> fail;
|
|
92
|
+
false
|
|
93
|
+
|
|
94
|
+
# Check POST method not allowed (405)
|
|
95
|
+
gap> r := PostToURL("www.google.com", "myfield=42");;
|
|
96
|
+
gap> SortedList(RecNames(r));
|
|
97
|
+
[ "result", "success" ]
|
|
98
|
+
gap> r.success;
|
|
99
|
+
true
|
|
100
|
+
gap> PositionSublist(r.result, "myfield") <> fail;
|
|
101
|
+
false
|
|
102
|
+
gap> PositionSublist(r.result, "405") <> fail;
|
|
103
|
+
true
|
|
104
|
+
|
|
105
|
+
# Check bad URL with POST
|
|
106
|
+
gap> r := PostToURL("https://www.google.cheesebadger", "hello");;
|
|
107
|
+
gap> SortedList(RecNames(r));
|
|
108
|
+
[ "error", "success" ]
|
|
109
|
+
gap> r.success;
|
|
110
|
+
false
|
|
111
|
+
gap> PositionSublist(r.error, "Could not resolve host") <> fail;
|
|
112
|
+
true
|
|
113
|
+
|
|
114
|
+
# Check not IsStringRep (url)
|
|
115
|
+
gap> url := List("https://www.google.com", letter -> letter);;
|
|
116
|
+
gap> IsStringRep(url);
|
|
117
|
+
false
|
|
118
|
+
gap> r := DownloadURL(url);;
|
|
119
|
+
gap> SortedList(RecNames(r));
|
|
120
|
+
[ "result", "success" ]
|
|
121
|
+
gap> r.success;
|
|
122
|
+
true
|
|
123
|
+
gap> PositionSublist(r.result, "google") <> fail;
|
|
124
|
+
true
|
|
125
|
+
|
|
126
|
+
# Check not IsStringRep (post_string)
|
|
127
|
+
gap> post_string := List("animal=tiger&material=cotton", letter -> letter);;
|
|
128
|
+
gap> IsStringRep(post_string);
|
|
129
|
+
false
|
|
130
|
+
gap> r := PostToURL("httpbun.com/post", post_string, rec(verifyCert := true));;
|
|
131
|
+
gap> r.success;
|
|
132
|
+
true
|
|
133
|
+
gap> PositionSublist(r.result, "\"animal\": \"tiger\"") <> fail;
|
|
134
|
+
true
|
|
135
|
+
gap> PositionSublist(r.result, "\"material\": \"cotton\"") <> fail;
|
|
136
|
+
true
|
|
137
|
+
gap> PositionSublist(r.result, "lion") <> fail;
|
|
138
|
+
false
|
|
139
|
+
|
|
140
|
+
# Check not IsStringRep (request type)
|
|
141
|
+
gap> r := CurlRequest("www.google.com", ['G', 'E', 'T'] , "");;
|
|
142
|
+
gap> r.success;
|
|
143
|
+
true
|
|
144
|
+
gap> SortedList(RecNames(r));
|
|
145
|
+
[ "result", "success" ]
|
|
146
|
+
gap> PositionSublist(r.result, "google") <> fail;
|
|
147
|
+
true
|
|
148
|
+
gap> PositionSublist(r.result, "tiger") <> fail;
|
|
149
|
+
false
|
|
150
|
+
|
|
151
|
+
# HEAD requests
|
|
152
|
+
gap> CurlRequest("www.google.com", "HEAD" , "");
|
|
153
|
+
rec( result := "", success := true )
|
|
154
|
+
gap> r := CurlRequest("www.google.cheesebadger", "HEAD" , "");;
|
|
155
|
+
gap> r.success;
|
|
156
|
+
false
|
|
157
|
+
|
|
158
|
+
# DELETE requests
|
|
159
|
+
gap> r := DeleteURL("https://www.google.com");;
|
|
160
|
+
gap> r.success;
|
|
161
|
+
true
|
|
162
|
+
gap> PositionSublist(r.result, "405 ") <> fail;
|
|
163
|
+
true
|
|
164
|
+
gap> PositionSublist(r.result, "tiger") <> fail;
|
|
165
|
+
false
|
|
166
|
+
gap> r := DeleteURL("httpbun.com/delete");;
|
|
167
|
+
gap> r.success;
|
|
168
|
+
true
|
|
169
|
+
gap> PositionSublist(r.result, "405 ") <> fail;
|
|
170
|
+
false
|
|
171
|
+
|
|
172
|
+
# Check verbose requests don't break anything (we can't catch the output here)
|
|
173
|
+
gap> r := DownloadURL("httpbun.com/get", rec(verbose := true));;
|
|
174
|
+
gap> r.success;
|
|
175
|
+
true
|
|
176
|
+
gap> PositionSublist(r.result, "httpbun") <> fail;
|
|
177
|
+
true
|
|
178
|
+
|
|
179
|
+
#gap> PositionSublist(r.result, "404 ") <> fail;
|
|
180
|
+
#false
|
|
181
|
+
|
|
182
|
+
# Follow redirects
|
|
183
|
+
gap> url := "http://www.icm.tu-bs.de/ag_algebra/software/polycyclic";;
|
|
184
|
+
gap> r := DownloadURL(url);;
|
|
185
|
+
gap> PositionSublist(r.result, "GitHub Pages") <> fail;
|
|
186
|
+
true
|
|
187
|
+
gap> r := DownloadURL(url, rec(followRedirect := true));;
|
|
188
|
+
gap> PositionSublist(r.result, "GitHub Pages") <> fail;
|
|
189
|
+
true
|
|
190
|
+
gap> r := DownloadURL(url, rec(followRedirect := false));;
|
|
191
|
+
gap> PositionSublist(r.result, "GitHub Pages") <> fail;
|
|
192
|
+
false
|
|
193
|
+
gap> PositionSublist(r.result, "301 ") <> fail;
|
|
194
|
+
true
|
|
195
|
+
|
|
196
|
+
# Check timeout works
|
|
197
|
+
gap> CurlRequest("www.google.com", "HEAD" , "", rec(maxTime := 1000000));
|
|
198
|
+
rec( result := "", success := true )
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#
|
|
2
|
+
# test error handling
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
# URL too long (Download)
|
|
6
|
+
gap> badURL := ListWithIdenticalEntries(4096,' ');;
|
|
7
|
+
gap> DownloadURL(badURL);
|
|
8
|
+
Error, CURL_REQUEST: <URL> must be less than 4096 chars
|
|
9
|
+
|
|
10
|
+
# URL too long (Post)
|
|
11
|
+
gap> badURL := ListWithIdenticalEntries(4096,' ');;
|
|
12
|
+
gap> PostToURL(badURL, "hello");
|
|
13
|
+
Error, CURL_REQUEST: <URL> must be less than 4096 chars
|
|
14
|
+
|
|
15
|
+
# URL not a string (Download)
|
|
16
|
+
gap> DownloadURL(42);
|
|
17
|
+
Error, CurlRequest: <URL> must be a string
|
|
18
|
+
|
|
19
|
+
# URL not a string (Post)
|
|
20
|
+
gap> PostToURL(42, "hello");
|
|
21
|
+
Error, CurlRequest: <URL> must be a string
|
|
22
|
+
|
|
23
|
+
# request type not a string
|
|
24
|
+
gap> CurlRequest("www.google.com", 637, "hello", rec(verifyCert := true));
|
|
25
|
+
Error, CurlRequest: <type> must be a string
|
|
26
|
+
|
|
27
|
+
# post_string not a string
|
|
28
|
+
gap> PostToURL("httpbun.com/post", 17);
|
|
29
|
+
Error, CurlRequest: <out_string> must be a string
|
|
30
|
+
|
|
31
|
+
# invalid verifyCert
|
|
32
|
+
gap> DownloadURL("https://www.google.com", rec(verifyCert := "maybe"));
|
|
33
|
+
Error, CurlRequest: <opts>.verifyCert must be true or false
|
|
34
|
+
|
|
35
|
+
# invalid verbose
|
|
36
|
+
gap> DownloadURL("https://www.google.com", rec(verbose := "yes"));
|
|
37
|
+
Error, CurlRequest: <opts>.verbose must be true or false
|
|
38
|
+
|
|
39
|
+
# invalid followRedirect
|
|
40
|
+
gap> DownloadURL("https://www.google.com", rec(followRedirect := "always"));
|
|
41
|
+
Error, CurlRequest: <opts>.followRedirect must be true or false
|
|
42
|
+
|
|
43
|
+
# invalid failOnError
|
|
44
|
+
gap> DownloadURL("https://www.google.com", rec(failOnError := "yes"));
|
|
45
|
+
Error, CurlRequest: <opts>.failOnError must be true or false
|
|
46
|
+
|
|
47
|
+
# invalid opts
|
|
48
|
+
gap> DownloadURL("https://www.google.com", "please verify the cert");
|
|
49
|
+
Error, CurlRequest: <opts> must be a record
|
|
50
|
+
|
|
51
|
+
# too many arguments
|
|
52
|
+
gap> CurlRequest("www.google.com", "GET", "", rec(verifyCert := true), 3, true);
|
|
53
|
+
Error, CurlRequest: usage: requires 3 or 4 arguments, but 6 were given
|
|
54
|
+
|
|
55
|
+
# invalid time
|
|
56
|
+
gap> CurlRequest("www.google.com", "GET", "", rec(maxTime := -1));
|
|
57
|
+
Error, CurlRequest: <opts>.maxTime must be a non-negative integer
|
|
58
|
+
|
|
59
|
+
# invalid time
|
|
60
|
+
gap> CurlRequest("www.google.com", "GET", "", rec(maxTime := "abc"));
|
|
61
|
+
Error, CurlRequest: <opts>.maxTime must be a non-negative integer
|
|
62
|
+
|
|
63
|
+
# number of arguments
|
|
64
|
+
gap> CURL_REQUEST();
|
|
65
|
+
Error, Function: number of arguments must be 8 (not 0)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#
|
|
2
|
+
# curlInterface: Simple Web Access
|
|
3
|
+
#
|
|
4
|
+
# This file runs package tests. It is also referenced in the package
|
|
5
|
+
# metadata in PackageInfo.g.
|
|
6
|
+
#
|
|
7
|
+
LoadPackage( "curlInterface" );
|
|
8
|
+
|
|
9
|
+
TestDirectory(DirectoriesPackageLibrary( "curlInterface", "tst" ),
|
|
10
|
+
rec(exitGAP := true));
|
|
11
|
+
|
|
12
|
+
FORCE_QUIT_GAP(1); # if we ever get here, there was an error
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: passagemath-gap-pkg-curlinterface
|
|
3
|
+
Version: 10.6.34
|
|
4
|
+
Summary: passagemath: Computational Group Theory with GAP: curlinterface package
|
|
5
|
+
Author-email: The Sage Developers <sage-support@googlegroups.com>
|
|
6
|
+
Maintainer: Matthias Köppe, passagemath contributors
|
|
7
|
+
License-Expression: GPL-2.0-or-later
|
|
8
|
+
Project-URL: release notes, https://github.com/passagemath/passagemath/releases
|
|
9
|
+
Project-URL: repo (upstream), https://github.com/sagemath/sage
|
|
10
|
+
Project-URL: repo, https://github.com/passagemath/passagemath
|
|
11
|
+
Project-URL: documentation, https://passagemath.org/docs/latest
|
|
12
|
+
Project-URL: homepage (upstream), https://www.sagemath.org
|
|
13
|
+
Project-URL: discourse, https://passagemath.discourse.group
|
|
14
|
+
Project-URL: tracker (upstream), https://github.com/sagemath/sage/issues
|
|
15
|
+
Project-URL: tracker, https://github.com/passagemath/passagemath/issues
|
|
16
|
+
Classifier: Development Status :: 6 - Mature
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Operating System :: POSIX
|
|
20
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
22
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
28
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
30
|
+
Requires-Python: <3.15,>=3.10
|
|
31
|
+
Description-Content-Type: text/x-rst
|
|
32
|
+
Requires-Dist: passagemath-environment~=10.6.34.0
|
|
33
|
+
|
|
34
|
+
=========================================================================
|
|
35
|
+
passagemath: Computational Group Theory with GAP: curlinterface package
|
|
36
|
+
=========================================================================
|
|
37
|
+
|
|
38
|
+
`passagemath <https://github.com/passagemath/passagemath>`__ is open
|
|
39
|
+
source mathematical software in Python, released under the GNU General
|
|
40
|
+
Public Licence GPLv2+.
|
|
41
|
+
|
|
42
|
+
It is a fork of `SageMath <https://www.sagemath.org/>`__, which has been
|
|
43
|
+
developed 2005-2025 under the motto “Creating a Viable Open Source
|
|
44
|
+
Alternative to Magma, Maple, Mathematica, and MATLAB”.
|
|
45
|
+
|
|
46
|
+
The passagemath fork uses the motto "Creating a Free Passage Between the
|
|
47
|
+
Scientific Python Ecosystem and Mathematical Software Communities."
|
|
48
|
+
It was created in October 2024 with the following goals:
|
|
49
|
+
|
|
50
|
+
- providing modularized installation with pip,
|
|
51
|
+
- establishing first-class membership in the scientific Python
|
|
52
|
+
ecosystem,
|
|
53
|
+
- giving `clear attribution of upstream
|
|
54
|
+
projects <https://groups.google.com/g/sage-devel/c/6HO1HEtL1Fs/m/G002rPGpAAAJ>`__,
|
|
55
|
+
- providing independently usable Python interfaces to upstream
|
|
56
|
+
libraries,
|
|
57
|
+
- offering `platform portability and integration testing
|
|
58
|
+
services <https://github.com/passagemath/passagemath/issues/704>`__
|
|
59
|
+
to upstream projects,
|
|
60
|
+
- inviting collaborations with upstream projects,
|
|
61
|
+
- `building a professional, respectful, inclusive
|
|
62
|
+
community <https://groups.google.com/g/sage-devel/c/xBzaINHWwUQ>`__,
|
|
63
|
+
- `empowering Sage users to participate in the scientific Python ecosystem
|
|
64
|
+
<https://github.com/passagemath/passagemath/issues/248>`__ by publishing packages,
|
|
65
|
+
- developing a port to `Pyodide <https://pyodide.org/en/stable/>`__ for
|
|
66
|
+
serverless deployment with Javascript,
|
|
67
|
+
- developing a native Windows port.
|
|
68
|
+
|
|
69
|
+
`Full documentation <https://passagemath.org/docs/latest/html/en/index.html>`__ is
|
|
70
|
+
available online.
|
|
71
|
+
|
|
72
|
+
passagemath attempts to support and provides binary wheels suitable for
|
|
73
|
+
all major Linux distributions and recent versions of macOS.
|
|
74
|
+
|
|
75
|
+
Binary wheels for native Windows (x86_64) are are available for a subset of
|
|
76
|
+
the passagemath distributions. Use of the full functionality of passagemath
|
|
77
|
+
on Windows currently requires the use of Windows Subsystem for Linux (WSL)
|
|
78
|
+
or virtualization.
|
|
79
|
+
|
|
80
|
+
The supported Python versions in the passagemath 10.6.x series are 3.10.x-3.13.x.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
About this pip-installable distribution package
|
|
84
|
+
-----------------------------------------------
|
|
85
|
+
|
|
86
|
+
This pip-installable distribution ``passagemath-gap-pkg-curlinterface`` is a
|
|
87
|
+
distribution of the GAP package ``curlinterface`` for use with ``passagemath-gap``.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
What is included
|
|
91
|
+
----------------
|
|
92
|
+
|
|
93
|
+
- Wheels on PyPI include the GAP package ``curlinterface``
|