ethon-impersonate 0.17.3-arm64-darwin-24

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +379 -0
  3. data/LICENSE +20 -0
  4. data/README.md +116 -0
  5. data/config/puma.rb +1 -0
  6. data/ethon-impersonate.gemspec +28 -0
  7. data/ext/libcurl-impersonate.4.dylib +0 -0
  8. data/lib/ethon/impersonate.rb +9 -0
  9. data/lib/ethon-impersonate.rb +1 -0
  10. data/lib/ethon_impersonate/curl.rb +90 -0
  11. data/lib/ethon_impersonate/curls/classes.rb +65 -0
  12. data/lib/ethon_impersonate/curls/codes.rb +122 -0
  13. data/lib/ethon_impersonate/curls/constants.rb +81 -0
  14. data/lib/ethon_impersonate/curls/form_options.rb +37 -0
  15. data/lib/ethon_impersonate/curls/functions.rb +59 -0
  16. data/lib/ethon_impersonate/curls/infos.rb +151 -0
  17. data/lib/ethon_impersonate/curls/messages.rb +19 -0
  18. data/lib/ethon_impersonate/curls/options.rb +503 -0
  19. data/lib/ethon_impersonate/curls/settings.rb +19 -0
  20. data/lib/ethon_impersonate/easy/callbacks.rb +149 -0
  21. data/lib/ethon_impersonate/easy/debug_info.rb +49 -0
  22. data/lib/ethon_impersonate/easy/features.rb +31 -0
  23. data/lib/ethon_impersonate/easy/form.rb +107 -0
  24. data/lib/ethon_impersonate/easy/header.rb +61 -0
  25. data/lib/ethon_impersonate/easy/http/actionable.rb +157 -0
  26. data/lib/ethon_impersonate/easy/http/custom.rb +29 -0
  27. data/lib/ethon_impersonate/easy/http/delete.rb +25 -0
  28. data/lib/ethon_impersonate/easy/http/get.rb +24 -0
  29. data/lib/ethon_impersonate/easy/http/head.rb +24 -0
  30. data/lib/ethon_impersonate/easy/http/options.rb +24 -0
  31. data/lib/ethon_impersonate/easy/http/patch.rb +24 -0
  32. data/lib/ethon_impersonate/easy/http/post.rb +26 -0
  33. data/lib/ethon_impersonate/easy/http/postable.rb +32 -0
  34. data/lib/ethon_impersonate/easy/http/put.rb +27 -0
  35. data/lib/ethon_impersonate/easy/http/putable.rb +25 -0
  36. data/lib/ethon_impersonate/easy/http.rb +68 -0
  37. data/lib/ethon_impersonate/easy/informations.rb +118 -0
  38. data/lib/ethon_impersonate/easy/mirror.rb +38 -0
  39. data/lib/ethon_impersonate/easy/operations.rb +64 -0
  40. data/lib/ethon_impersonate/easy/options.rb +50 -0
  41. data/lib/ethon_impersonate/easy/params.rb +29 -0
  42. data/lib/ethon_impersonate/easy/queryable.rb +154 -0
  43. data/lib/ethon_impersonate/easy/response_callbacks.rb +136 -0
  44. data/lib/ethon_impersonate/easy/util.rb +28 -0
  45. data/lib/ethon_impersonate/easy.rb +332 -0
  46. data/lib/ethon_impersonate/errors/ethon_error.rb +9 -0
  47. data/lib/ethon_impersonate/errors/global_init.rb +13 -0
  48. data/lib/ethon_impersonate/errors/invalid_option.rb +13 -0
  49. data/lib/ethon_impersonate/errors/invalid_value.rb +13 -0
  50. data/lib/ethon_impersonate/errors/multi_add.rb +12 -0
  51. data/lib/ethon_impersonate/errors/multi_fdset.rb +12 -0
  52. data/lib/ethon_impersonate/errors/multi_remove.rb +12 -0
  53. data/lib/ethon_impersonate/errors/multi_timeout.rb +13 -0
  54. data/lib/ethon_impersonate/errors/select.rb +13 -0
  55. data/lib/ethon_impersonate/errors.rb +17 -0
  56. data/lib/ethon_impersonate/impersonate/fingerprints.rb +16 -0
  57. data/lib/ethon_impersonate/impersonate/settings.rb +89 -0
  58. data/lib/ethon_impersonate/impersonate/targets.rb +89 -0
  59. data/lib/ethon_impersonate/impersonate/tls.rb +189 -0
  60. data/lib/ethon_impersonate/impersonate.rb +10 -0
  61. data/lib/ethon_impersonate/libc.rb +21 -0
  62. data/lib/ethon_impersonate/loggable.rb +59 -0
  63. data/lib/ethon_impersonate/multi/operations.rb +228 -0
  64. data/lib/ethon_impersonate/multi/options.rb +117 -0
  65. data/lib/ethon_impersonate/multi/stack.rb +49 -0
  66. data/lib/ethon_impersonate/multi.rb +126 -0
  67. data/lib/ethon_impersonate/version.rb +6 -0
  68. data/lib/ethon_impersonate.rb +28 -0
  69. metadata +123 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3a3f79a9adf6f63fe4bc22ebcb3de6dbc67373c65ff826393f0472f96ee080b2
4
+ data.tar.gz: 922e6c6cc35a012ce5e4484b922924f4c4d9c3563c2e04f3578c85b583b4782f
5
+ SHA512:
6
+ metadata.gz: e2247f2c3bae599100305aa14baa170b0bdd0472e48463f2b52e648009c69d2601578a9dbaeec65345a993a78fcc56aed762cea7f82ed30ebfd36e7e86b40dbb
7
+ data.tar.gz: d353e4c0600383de771c87df4e9c6e11e8372f599bcd49b14352509053e2f3438facb96d33deb323cd6293eed002aa66fc5ca638207328ce9d6c604c9f391ba1
data/CHANGELOG.md ADDED
@@ -0,0 +1,379 @@
1
+ # Changelog
2
+
3
+ ## Master
4
+
5
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.16.0...master)
6
+
7
+ ## 0.16.0
8
+
9
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.15.0...v0.16.0)
10
+
11
+ * Added `redirect_url` value to available informations and `Easy::Mirror`.
12
+ ([Adrien Rey-Jarthon](https://github.com/jarthod)
13
+
14
+ ## 0.15.0
15
+
16
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.14.0...v0.15.0)
17
+
18
+ ## 0.12.0
19
+
20
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.11.0...v0.12.0)
21
+
22
+ - Removed deprecated `CURLE_SSL_CACERT` pinned in curl v7.62.0 ([@arku](https://github.com/arku) in [#158](https://github.com/dsojevic/ethon-impersonate/pull/158))
23
+
24
+
25
+ ## 0.11.0
26
+
27
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.10.1...v0.11.0)
28
+
29
+ ## 0.10.1
30
+
31
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.10.0...v0.10.1)
32
+
33
+ ## 0.10.0
34
+
35
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.9.1...v0.10.0)
36
+
37
+ ## 0.9.1
38
+
39
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.9.0...v0.9.1)
40
+
41
+ ## 0.9.0
42
+
43
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.8.1...v0.9.0)
44
+
45
+ ## 0.8.1
46
+
47
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.8.0...v0.8.1)
48
+
49
+ * Support optional escaping of params.
50
+ ([Tasos Laskos](https://github.com/zapotek)
51
+ * `Easy::Mirror`: Reduced object allocations and method calls during info handling.
52
+ ([Tasos Laskos](https://github.com/zapotek)
53
+
54
+ ## 0.8.0
55
+
56
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.7.3...v0.7.4)
57
+
58
+ * `Easy::Mirror`: Reduced object allocations and method calls during info handling.
59
+ ([Tasos Laskos](https://github.com/zapotek)
60
+
61
+ ## 0.7.4
62
+
63
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.7.3...v0.7.4)
64
+
65
+ * Support different array encodings for params.
66
+ ([Marcello Barnaba](https://github.com/ifad), [\#104](https://github.com/dsojevic/ethon-impersonate/pull/104))
67
+ * Programtic access to version infos.
68
+ ([Jonas Wagner](https://github.com/jwagner), [\#90](https://github.com/dsojevic/ethon-impersonate/pull/90))
69
+
70
+
71
+ ## 0.7.3
72
+
73
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.7.2...v0.7.3)
74
+
75
+ * `EthonImpersonate::Curl::FDSet`
76
+ * Set `:fd_array` size to the current MS Windows `FD_SETSIZE` (2048).
77
+ ([Tasos Laskos](https://github.com/zapotek)
78
+
79
+ * Added `redirect_time` value to available informations and `Easy::Mirror`.
80
+ ([Adrien Jarthon](https://github.com/jarthod)
81
+
82
+ ## 0.7.2
83
+
84
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.7.1...v0.7.2)
85
+
86
+ * FFI data-types updated to be more correct.
87
+
88
+ ## 0.7.1
89
+
90
+ * MS Windows determination delegated to `Gem.windows?` for better accuracy.
91
+ * FFI data-types updated to work on MS Windows.
92
+
93
+ ## 0.7.0
94
+
95
+ Not backwards compatible changes:
96
+
97
+ * `mime-types` are no longer a dependency. The gem will be still used if available to determine the mime type of a file which is uploaded. That means you have to have take care of the gem installation yourself.
98
+
99
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.6.3...v0.7.0)
100
+
101
+ ## 0.6.3
102
+
103
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.6.2...v0.6.3)
104
+
105
+ ## 0.6.2
106
+
107
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.6.1...v0.6.2)
108
+
109
+ ## 0.6.1
110
+
111
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.6.0...v0.6.1)
112
+
113
+ The changelog entries are coming soon!
114
+
115
+ ## 0.6.0
116
+
117
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.12...v0.6.0)
118
+
119
+ The changelog entries are coming soon!
120
+
121
+ Bugfixes:
122
+
123
+ * URL-encode nullbytes in parameters instead of escaping them to `\\0`.
124
+ ([Tasos Laskos](https://github.com/zapotek)
125
+
126
+ ## 0.5.12
127
+
128
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.11...v0.5.12)
129
+
130
+ Enhancements:
131
+
132
+ * Performance optimizations.
133
+ ([Kyle Oppenheim](https://github.com/koppenheim) and [Richie Vos](https://github.com/richievos), [\#48](https://github.com/dsojevic/ethon-impersonate/pull/48))
134
+ * Reuse memory pointer.
135
+ ([Richie Vos](https://github.com/richievos), [\#49](https://github.com/dsojevic/ethon-impersonate/pull/49))
136
+
137
+ Bugfixes:
138
+
139
+ * Fix windows install.
140
+ ([Derik Olsson](https://github.com/derikolsson), [\#47](https://github.com/dsojevic/ethon-impersonate/pull/47))
141
+ * Handle urls that already contain query params.
142
+ ([Turner King](https://github.com/turnerking ), [\#45](https://github.com/dsojevic/ethon-impersonate/pull/45))
143
+
144
+ ## 0.5.11
145
+
146
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.10...v0.5.11)
147
+
148
+ Enhancements:
149
+
150
+ * Add support for postredirs, unrestricted_auth.
151
+ * Add support for cookie, cookiejar, cookiefile.
152
+ ([erwanlr](https://github.com/erwanlr), [\#46](https://github.com/dsojevic/ethon-impersonate/pull/46))
153
+ * Relax ffi requirements.
154
+ ([voxik](https://github.com/voxik), [\#40](https://github.com/dsojevic/ethon-impersonate/pull/40))
155
+ * Various documentation improvements.
156
+ ([Craig Little](https://github.com/craiglittle))
157
+
158
+ Bugfixes:
159
+
160
+ * Fix the memory leaks.
161
+ ([Richie Vos](https://github.com/richievos), [\#45](https://github.com/dsojevic/ethon-impersonate/pull/45))
162
+
163
+ ## 0.5.10
164
+
165
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.9...v0.5.10)
166
+
167
+ Enhancements:
168
+
169
+ * Allow custom requests.
170
+ ([Nathan Sutton](https://github.com/nate), [\#36](https://github.com/dsojevic/ethon-impersonate/pull/36))
171
+ * Use updated version of FFI.
172
+
173
+ Bugfixes:
174
+
175
+ * Fix windows install issue.
176
+ ([brainsucker](https://github.com/brainsucker), [\#38](https://github.com/dsojevic/ethon-impersonate/pull/38))
177
+
178
+ ## 0.5.9
179
+
180
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.8...v0.5.9)
181
+
182
+ Enhancements:
183
+
184
+ * Allow to set multiple protocols.
185
+
186
+ ## 0.5.8
187
+
188
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.7...v0.5.8)
189
+
190
+ Enhancements:
191
+
192
+ * Add support for protocols and redir_protocols(
193
+ [libcurl SASL buffer overflow vulnerability](http://curl.haxx.se/docs/adv_20130206.html)).
194
+ * Add max_send_speed_large and max_recv_speed_large([Paul Schuegraf](https://github.com/pschuegr), [\#33](https://github.com/dsojevic/ethon-impersonate/pull/33))
195
+
196
+ ## 0.5.7
197
+
198
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.6...v0.5.7)
199
+
200
+ Enhancements:
201
+
202
+ * Use new version of ffi.
203
+
204
+ ## 0.5.6
205
+
206
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.4...v0.5.6)
207
+
208
+ Bugfixes:
209
+
210
+ * Easy#reset resets on_complete callbacks.
211
+
212
+ ## 0.5.4
213
+
214
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.3...v0.5.4)
215
+
216
+ Enhancements:
217
+
218
+ * Use Libc#getdtablesize to get the FDSet size.
219
+ * New libcurl option accept_encoding.
220
+ * Documentation updates.
221
+
222
+ ## 0.5.3
223
+
224
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.2...v0.5.3)
225
+
226
+ Enhancements:
227
+
228
+ * Deprecate Easy#prepare. It is no longer necessary.
229
+ * Unroll metaprogramming for easy and multi options.
230
+ * More specs.
231
+
232
+ Bugfixes:
233
+
234
+ * Correct size for FDSets
235
+ * Add proxytypes to enums.
236
+
237
+ ## 0.5.2
238
+
239
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.1...v0.5.2)
240
+
241
+ Enhancements:
242
+
243
+ * New libcurl option keypasswd.
244
+
245
+ Bugfixes:
246
+
247
+ * Correct request logging when using multi interface.
248
+ * Remove invalid libcurl option sslcertpasswd.
249
+
250
+ ## 0.5.1
251
+
252
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.5.0...v0.5.1)
253
+
254
+ Bugfixes:
255
+
256
+ * Mark Curl.select and Curl.easy_perform as blocking so that the GIL is
257
+ released by ffi.
258
+
259
+ ## 0.5.0
260
+
261
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.4.4...v0.5.0)
262
+
263
+ Enhancements:
264
+
265
+ * New libcurl option proxyuserpwd
266
+ * Rename response_header to response_headers
267
+
268
+ Bugfixes:
269
+
270
+ * Mark Curl.select and Curl.easy_perform as blocking so that the GIL is
271
+ released by ffi.
272
+
273
+ ## 0.4.4
274
+
275
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.4.3...v0.4.4)
276
+
277
+ Enhancements:
278
+
279
+ * Prepare multi explicit like easy
280
+
281
+ ## 0.4.3
282
+
283
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.4.2...v0.4.3)
284
+
285
+ Enhancements:
286
+
287
+ * Remove deprecated libcurl option put
288
+ * More documentation
289
+ * New libcurl option connecttimeout_ms and timeout_ms
290
+ * Support multi options
291
+
292
+ Bugfixes:
293
+
294
+ * Handle nil values in query params
295
+
296
+ ## 0.4.2
297
+
298
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.4.1...v0.4.2)
299
+
300
+ Enhancements:
301
+
302
+ * New libcurl option forbid_reuse
303
+ * Use libcurls escape instead of CGI::escape
304
+
305
+ ## 0.4.1
306
+
307
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.4.0...v0.4.1)
308
+
309
+ Bugfixes:
310
+
311
+ * Handle nested hash in an array in params correct
312
+ ( [\#201](https://github.com/typhoeus/typhoeus/issues/201) )
313
+
314
+ ## 0.4.0
315
+
316
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.3.0...v0.4.0)
317
+
318
+ Enhancements:
319
+
320
+ * ruby 1.8.7 compatible
321
+ * EthonImpersonate.logger
322
+ * Deal with string param/body
323
+ * More documentation
324
+
325
+ Bugfixes:
326
+
327
+ * Add multi_cleanup to curl
328
+
329
+ ## 0.3.0
330
+
331
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.2.0...v0.3.0)
332
+
333
+ Enhancements:
334
+
335
+ * New libcurl option proxyport
336
+ * Raise invalid value error when providing a wrong key for sslversion or httpauth
337
+
338
+ Bugfixes:
339
+
340
+ * Libcurl option sslversion is handled correct
341
+
342
+ ## 0.2.0
343
+
344
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.1.0...v0.2.0)
345
+
346
+ Enhancements:
347
+
348
+ * GET requests are using custom requests only when there is a request body
349
+ * Easy#on_complete takes multiple callbacks
350
+ * raise Errors::GlobalInit when libcurls global_init failed instead of
351
+ runtime error
352
+ * raise Errors::InvalidOption if option is invalid
353
+
354
+ ## 0.1.0
355
+
356
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.0.2...v0.1.0)
357
+
358
+ Enhancements:
359
+
360
+ * Documentation
361
+ ( [Alex P](https://github.com/ifesdjeen), [\#13](https://github.com/dsojevic/ethon-impersonate/issues/13) )
362
+ * New libcurl option dns_cache_timeout
363
+ ( [Chris Heald](https://github.com/cheald), [\#192](https://github.com/typhoeus/typhoeus/pull/192) )
364
+
365
+ Bugfixes:
366
+
367
+ * Libcurl option ssl_verifyhost takes an integer.
368
+ * Add space between header key and value.
369
+
370
+ ## 0.0.2
371
+
372
+ [Full Changelog](https://github.com/dsojevic/ethon-impersonate/compare/v0.0.1...v0.0.2)
373
+
374
+ Bugfixes:
375
+
376
+ * Add libcurl.so.4 to ffi_lib in order to load correct lib on Debian.
377
+ * Escape zero bytes.
378
+
379
+ ## 0.0.1 Initial version
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-2016 Hans Hasselberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ [![Gem Version](https://badge.fury.io/rb/ethon-impersonate.svg)](https://badge.fury.io/rb/ethon-impersonate)
2
+ [![Build Status](https://github.com/dsojevic/ethon-impersonate/workflows/Ruby/badge.svg)](https://github.com/dsojevic/ethon-impersonate/actions/workflows/ruby.yml)
3
+
4
+ # Ethon Impersonate
5
+
6
+ In Greek mythology, Ethon, the son of Typhoeus and Echidna, is a gigantic eagle. So much for the history.
7
+ In the modern world, Ethon is a very basic libcurl wrapper using ffi.
8
+
9
+ ## Installation
10
+
11
+ With bundler:
12
+ ```bash
13
+ gem "ethon-impersonate"
14
+ ```
15
+
16
+ With rubygems:
17
+ ```bash
18
+ gem install ethon-impersonate
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Making the first request is simple:
24
+
25
+ ```ruby
26
+ easy = EthonImpersonate::Easy.new(url: "www.example.com")
27
+ easy.perform
28
+ #=> :ok
29
+ ```
30
+
31
+ You have access to various options, such as following redirects:
32
+
33
+ ```ruby
34
+ easy = EthonImpersonate::Easy.new(url: "www.example.com", followlocation: true)
35
+ easy.perform
36
+ #=> :ok
37
+ ```
38
+
39
+ Once you're done you can inspect the response code and body:
40
+
41
+ ```ruby
42
+ easy = EthonImpersonate::Easy.new(url: "www.example.com", followlocation: true)
43
+ easy.perform
44
+ easy.response_code
45
+ #=> 200
46
+ easy.response_body
47
+ #=> "<!doctype html><html ..."
48
+ ```
49
+
50
+ ## Http
51
+
52
+ In order to make life easier, there are some helpers for making HTTP requests:
53
+
54
+ ```ruby
55
+ easy = EthonImpersonate::Easy.new
56
+ easy.http_request("www.example.com", :get, { params: {a: 1} })
57
+ easy.perform
58
+ #=> :ok
59
+ ```
60
+
61
+ ```ruby
62
+ easy = EthonImpersonate::Easy.new
63
+ easy.http_request("www.example.com", :post, { params: { a: 1 }, body: { b: 2 } })
64
+ easy.perform
65
+ #=> :ok
66
+ ```
67
+
68
+ This is really handy when making requests since you don't have to care about setting
69
+ everything up correctly.
70
+
71
+ ## Http2
72
+ Standard http2 servers require the client to connect once and create a session (multi) and then add simple requests to the multi handler.
73
+ The `perform` method then takes all the requests in the multi handler and sends them to the server.
74
+
75
+ See the following example
76
+ ```ruby
77
+ multi = EthonImpersonate::Multi.new
78
+ easy = EthonImpersonate::Easy.new
79
+
80
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_0 })
81
+
82
+ # Sending a request with http version 2 will send an Upgrade header to the server, which many older servers will not support
83
+ # See below for more info: https://everything.curl.dev/http/http2
84
+ # If this is a problem, send the below:
85
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_prior_knowledge })
86
+
87
+ # To set the server to use http2 with https and http1 with http, send the following:
88
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_tls })
89
+
90
+ multi.add(easy)
91
+ multi.perform
92
+ ```
93
+
94
+ ## LICENSE
95
+
96
+ (The MIT License)
97
+
98
+ Copyright © 2012-2016 [Hans Hasselberg](http://www.hans.io)
99
+
100
+ Permission is hereby granted, free of charge, to any person obtaining a
101
+ copy of this software and associated documentation files (the "Software"),
102
+ to deal in the Software without restriction, including without
103
+ limitation the rights to use, copy, modify, merge, publish, distribute,
104
+ sublicense, and/or sell copies of the Software, and to permit persons
105
+ to whom the Software is furnished to do so, subject to the following conditions:
106
+
107
+ The above copyright notice and this permission notice shall be included
108
+ in all copies or substantial portions of the Software.
109
+
110
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
111
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
112
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
113
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
114
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
115
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
116
+ OTHER DEALINGS IN THE SOFTWARE.
data/config/puma.rb ADDED
@@ -0,0 +1 @@
1
+ ENV['OBJC_DISABLE_INITIALIZE_FORK_SAFETY'] = 'YES'
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path("../lib/", __FILE__)
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require "ethon_impersonate/version"
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "ethon-impersonate"
10
+ s.version = EthonImpersonate::VERSION
11
+ s.authors = ["David Sojevic", "Hans Hasselberg"]
12
+ s.email = ["david@sojevic.com"]
13
+ s.homepage = "https://github.com/dsojevic/ethon-impersonate"
14
+ s.summary = "Impersonate browser-like HTTP requests."
15
+ s.description = "Realistic browser-like HTTP requests using curl-impersonate's impersonation capabilities."
16
+
17
+ s.required_ruby_version = ">= 2.7"
18
+ s.required_rubygems_version = ">= 1.3.6"
19
+ s.license = "MIT"
20
+
21
+ s.add_dependency("ffi", ["~> 1.15"])
22
+
23
+ s.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0") + Dir.glob("ext/**/*")
25
+ end.reject { |file| file.start_with?(*%w[. Gemfile Guardfile Rakefile profile spec scripts]) || file.end_with?(".gitignore") }
26
+
27
+ s.require_path = "lib"
28
+ end
Binary file
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ require 'ethon/impersonate/fingerprints'
3
+ require 'ethon/impersonate/targets'
4
+ require 'ethon/impersonate/tls'
5
+
6
+ module Ethon
7
+ module Impersonate
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require "ethon_impersonate"
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+ require 'ethon_impersonate/curls/codes'
3
+ require 'ethon_impersonate/curls/options'
4
+ require 'ethon_impersonate/curls/infos'
5
+ require 'ethon_impersonate/curls/form_options'
6
+ require 'ethon_impersonate/curls/messages'
7
+ require 'ethon_impersonate/curls/functions'
8
+
9
+ module EthonImpersonate
10
+
11
+ # FFI Wrapper module for Curl. Holds constants and required initializers.
12
+ #
13
+ # @api private
14
+ module Curl
15
+ extend ::FFI::Library
16
+ extend EthonImpersonate::Curls::Codes
17
+ extend EthonImpersonate::Curls::Options
18
+ extend EthonImpersonate::Curls::Infos
19
+ extend EthonImpersonate::Curls::FormOptions
20
+ extend EthonImpersonate::Curls::Messages
21
+
22
+ # :nodoc:
23
+ def self.windows?
24
+ Libc.windows?
25
+ end
26
+
27
+ require 'ethon_impersonate/curls/constants'
28
+ require 'ethon_impersonate/curls/settings'
29
+ require 'ethon_impersonate/curls/classes'
30
+ extend EthonImpersonate::Curls::Functions
31
+
32
+ @blocking = true
33
+
34
+ @@initialized = false
35
+ @@curl_mutex = Mutex.new
36
+
37
+ class << self
38
+ # This function sets up the program environment that libcurl needs.
39
+ # Think of it as an extension of the library loader.
40
+ #
41
+ # This function must be called at least once within a program (a program is all the
42
+ # code that shares a memory space) before the program calls any other function in libcurl.
43
+ # The environment it sets up is constant for the life of the program and is the same for
44
+ # every program, so multiple calls have the same effect as one call.
45
+ #
46
+ # The flags option is a bit pattern that tells libcurl exactly what features to init,
47
+ # as described below. Set the desired bits by ORing the values together. In normal
48
+ # operation, you must specify CURL_GLOBAL_ALL. Don't use any other value unless
49
+ # you are familiar with it and mean to control internal operations of libcurl.
50
+ #
51
+ # This function is not thread safe. You must not call it when any other thread in
52
+ # the program (i.e. a thread sharing the same memory) is running. This doesn't just
53
+ # mean no other thread that is using libcurl. Because curl_global_init() calls
54
+ # functions of other libraries that are similarly thread unsafe, it could conflict with
55
+ # any other thread that uses these other libraries.
56
+ #
57
+ # @raise [ EthonImpersonate::Errors::GlobalInit ] If Curl.global_init fails.
58
+ def init
59
+ @@curl_mutex.synchronize {
60
+ if not @@initialized
61
+ raise Errors::GlobalInit.new if Curl.global_init(GLOBAL_ALL) != 0
62
+ @@initialized = true
63
+ EthonImpersonate.logger.debug("ETHON: Libcurl initialized") if EthonImpersonate.logger
64
+ end
65
+ }
66
+ end
67
+
68
+ # This function releases resources acquired by curl_global_init.
69
+ # You should call curl_global_cleanup once for each call you make to
70
+ # curl_global_init, after you are done using libcurl.
71
+ # This function is not thread safe. You must not call it when any other thread in the
72
+ # program (i.e. a thread sharing the same memory) is running. This doesn't just
73
+ # mean no other thread that is using libcurl. Because curl_global_cleanup calls functions of other
74
+ # libraries that are similarly thread unsafe, it could conflict with
75
+ # any other thread that uses these other libraries.
76
+ # See the description in libcurl of global environment requirements
77
+ # for details of how to use this function.
78
+ def cleanup
79
+ @@curl_mutex.synchronize {
80
+ if @@initialized
81
+ Curl.global_cleanup()
82
+ @@initialized = false
83
+ EthonImpersonate.logger.debug("ETHON: Libcurl cleanup") if EthonImpersonate.logger
84
+ end
85
+ }
86
+ end
87
+
88
+ end
89
+ end
90
+ end