HTTPS: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Initial FutureBasic task solution added) |
m (→{{header|Wren}}: Minor tidy) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 122:
<syntaxhighlight lang="d">
import std.net.curl;
auto data = get("https://sourceforge.net");
writeln(data);
Line 234 ⟶ 236:
=={{header|Frink}}==
<syntaxhighlight lang="frink">print[read["https://sourceforge.net/"]]</syntaxhighlight>
=={{header|Go}}==▼
<syntaxhighlight lang="go">▼
package main▼
▲import (
"io"▼
"log"▼
"net/http"▼
"os"▼
)▼
func main() {▼
r, err := http.Get("https://sourceforge.net/")▼
if err != nil {▼
log.Fatalln(err)▼
}▼
io.Copy(os.Stdout, r.Body)▼
}▼
</syntaxhighlight>▼
=={{header|FutureBasic}}==
Line 261 ⟶ 242:
local fn GET_HTTPS
CFStringRef
CFDataRef dta = fn StringData(
CFDictionaryRef options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
CFAttributedStringRef aStr = fn AttributedStringWithHTML( dta, options )
Line 282 ⟶ 263:
NSStrokeWidth = 0;
}
</pre>▼
▲=={{header|Go}}==
▲<syntaxhighlight lang="go">
▲package main
import (
▲ "io"
▲ "log"
▲ "net/http"
▲ "os"
▲)
▲func main() {
▲ r, err := http.Get("https://sourceforge.net/")
▲ if err != nil {
▲ log.Fatalln(err)
▲ }
▲ io.Copy(os.Stdout, r.Body)
▲}
▲</syntaxhighlight>
▲</pre>
=={{header|Groovy}}==
<syntaxhighlight lang="groovy">
Line 380 ⟶ 381:
=={{header|JavaScript}}==
=== Browser ===
Using fetch API and async/await:
<syntaxhighlight lang="javascript">
const text = await response.text();
console.log(text);
</syntaxhighlight>
<syntaxhighlight lang="javascript">fetch("https://sourceforge.net").then(function (response) {
return response.text();
Line 385 ⟶ 395:
return body;
});</syntaxhighlight>
=== Node.js ===
<syntaxhighlight lang="javascript">require("https").get("https://sourceforge.net", function (resp) {
Line 676 ⟶ 687:
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
Invoke-WebRequest 'https://www.rosettacode.org'
</syntaxhighlight>
<syntaxhighlight lang="powershell">
$wc = New-Object Net.WebClient
Line 845 ⟶ 860:
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">
require('LWP::Protocol::https')
▲var url = 'https://rosettacode.org';
func get(url) {
static ua = %O<LWP::UserAgent>.new(
ssl_opts => Hash
)
if (resp.is_success) {
return resp.decoded_content
}
}
say get("https://rosettacode.org")</syntaxhighlight>
▲var resp = ua.get(url);
▲resp.is_success || die "Failed to GET #{url.dump}: #{resp.status_line}";
=={{header|Swift}}==
Line 974 ⟶ 994:
{{libheader|libcurl}}
An embedded program so we can ask the C host to communicate with libcurl for us.
<syntaxhighlight lang="
var CURLOPT_URL = 10002
Line 1,007 ⟶ 1,027:
<br>
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc
#include <stdio.h>
Line 1,117 ⟶ 1,137:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
|