HTTP: Difference between revisions

101 bytes removed ,  5 months ago
m
imported>Gabrielsroka
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
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}}==
Line 2,818 ⟶ 2,817:
{{libheader|libcurl}}
An embedded program so we can ask the C host to communicate with libcurl for us.
<syntaxhighlight lang="ecmascriptwren">/* httpHTTP.wren */
 
var CURLOPT_URL = 10002
Line 2,851 ⟶ 2,850:
<br>
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc httpHTTP.c -o httpHTTP -lcurl -lwren -lm */
 
#include <stdio.h>
Line 2,961 ⟶ 2,960:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "httpHTTP.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
9,477

edits