HTTP: Difference between revisions

95 bytes removed ,  6 months ago
→‎{{header|Sidef}}: use "HTTP::Tiny", which is a core module
imported>Gabrielsroka
(→‎{{header|Sidef}}: use "HTTP::Tiny", which is a core module)
Line 2,643:
=={{header|Sidef}}==
Sidef can load and use Perl modules:
<syntaxhighlight lang="ruby">func getrequire(url'HTTP::Tiny') {
 
var lwp = (
func get(url) {
try { require('LWP::UserAgent') }
varstatic ua = lwp%O<HTTP::Tiny>.new(agent => 'Mozilla/5.0')
catch { warn "'LWP::UserAgent' is not installed!"; return nil }
var lwpresp = ua.get(url)
)
if (resp{:success}) {
var ua = lwp.new(agent => 'Mozilla/5.0')
if (var resp = ua.get(url);return resp{:content}.is_success) {decode_utf8
return resp.decoded_content
}
return nil
}
 
printsay get("http://rosettacode.org")</syntaxhighlight>
 
=={{header|Smalltalk}}==
2,747

edits