-
Notifications
You must be signed in to change notification settings - Fork 0
/
requests.para
262 lines (226 loc) · 8.21 KB
/
requests.para
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
let requests = Type.extend({
name = 'Requests'
func get(_, url, params=null, *args) {
return intern_list_to_response(__intern_requests_get__(url, params, *args));
}
func post(_, url, data=null, json=null, *args) {
return intern_list_to_response(__intern_requests_post__(url, data, json, *args));
}
func put(_, url, data=null, *args) {
return intern_list_to_response(__intern_requests_put__(url, data, *args));
}
func head(_, url, *args) {
return intern_list_to_response(__intern_requests_head__(url, *args));
}
func delete(_, url, *args) {
return intern_list_to_response(__intern_requests_delete__(url, *args));
}
func patch(_, url, *args) {
return intern_list_to_response(__intern_requests_patch__(url, *args));
}
func request(_, method, url, *args) {
return intern_list_to_response(__intern_requests_request__(method, url, *args));
}
});
let Response = Type.extend({
name = 'Response'
instance = {
url
text
status_code
request
reason
ok
next
links
is_redirect
is_permanent_redirect
history
headers
encoding
elapsed
//cookies
content
apparent_encoding
//raise_for_status = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_response_raise_for_status__(*args);
// }
// }
//}).new()
//json = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_response_json__(*args);
// }
// }
//}).new()
//iter_lines = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_response_iter_lines__(*args);
// }
// }
//}).new()
//iter_content = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_response_iter_content__(*args);
// }
// }
//}).new()
//close = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_response_close__(*args);
// }
// }
//}).new()
}
func __construct__(self, _url, _text, _status_code, _request, _reason, _ok, _next, _links, _is_redirect, _is_permanent_redirect, _history, _headers, _encoding, _elapsed, _content, _apparent_encoding) {
self.url = _url;
self.text = _text;
self.status_code = _status_code;
self.request = _request;
self.reason = _reason;
self.ok = _ok;
self.next = _next;
self.links = _links;
self.is_redirect = _is_redirect;
self.is_permanent_redirect = _is_permanent_redirect;
self.history = _history;
self.headers = _headers;
self.encoding = _encoding;
self.elapsed = _elapsed;
//self.cookies = _cookies;
self.content = _content;
self.apparent_encoding = _apparent_encoding;
return self;
}
});
let PreparedRequest = Type.extend({
name = 'PreparedRequest'
instance = {
body
headers
hooks
method
path_url
url
//deregister_hook = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_deregister_hook__(*args);
// }
// }
//}).new()
//prepare = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare__(*args);
// }
// }
//}).new()
//prepare_auth = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_auth__(*args);
// }
// }
//}).new()
//prepare_body = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_body__(*args);
// }
// }
//}).new()
//prepare_content_length = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_content_length__(*args);
// }
// }
//}).new()
//prepare_cookies = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_cookies__(*args);
// }
// }
//}).new()
//prepare_headers = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_headers__(*args);
// }
// }
//}).new()
//prepare_hooks = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_hooks__(*args);
// }
// }
//}).new()
//prepare_method = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_method__(*args);
// }
// }
//}).new()
//prepare_url = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_prepare_url__(*args);
// }
// }
//}).new()
//register_hook = Func.extend({
// instance = {
// func __call__(self, _args) {
// let args = _args.from(1);
// return __intern_requests_preparedrequest_register_hook__(*args);
// }
// }
//}).new()
func to_str(self) {
return "PreparedRequest(" + self.method + ")";
}
}
func __construct__(self, _body, _headers, _hooks, _method, _path_url, _url) {
self.body = _body;
self.headers = _headers;
self.hooks = _hooks;
self.method = _method;
self.path_url = _path_url;
self.url = _url;
return self;
}
});
func intern_list_to_response(values) {
import "std/time.para";
let result = Response.new(values[0], values[1], values[2], PreparedRequest.new(values[3][0], CaseInsensitiveDict.new(values[3][1][0], values[3][1][1]), Dict.new(values[3][2][0], values[3][2][1]), values[3][3], values[3][4], values[3][5]), values[4], Bool.new(values[5]), values[6], Dict.new(values[7][0], values[7][1]), Bool.new(values[8]), Bool.new(values[9]), [], CaseInsensitiveDict.new(values[3][1][0], values[3][1][1]), values[12], TimeDelta.new(values[13][0], values[13][1], values[13][2], values[13][3], values[13][4], values[13][5], values[13][6]), values[14], values[15]);
for r in values[10] {
result.history.append(intern_list_to_response(r));
}
return result;
}
//let x = requests.delete("https://w3schools.com/python/demopage.htm");