HTTP: Difference between revisions

Content added Content deleted
imported>Gabrielsroka
(→‎{{header|Sidef}}: use "HTTP::Tiny", which is a core module)
Line 2,643: Line 2,643:
=={{header|Sidef}}==
=={{header|Sidef}}==
Sidef can load and use Perl modules:
Sidef can load and use Perl modules:
<syntaxhighlight lang="ruby">func get(url) {
<syntaxhighlight lang="ruby">require('HTTP::Tiny')

var lwp = (
func get(url) {
try { require('LWP::UserAgent') }
static ua = %O<HTTP::Tiny>.new(agent => 'Mozilla/5.0')
catch { warn "'LWP::UserAgent' is not installed!"; return nil }
var resp = ua.get(url)
)
if (resp{:success}) {
var ua = lwp.new(agent => 'Mozilla/5.0')
if (var resp = ua.get(url); resp.is_success) {
return resp{:content}.decode_utf8
return resp.decoded_content
}
}
return nil
return nil
}
}


print get("http://rosettacode.org")</syntaxhighlight>
say get("http://rosettacode.org")</syntaxhighlight>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==