A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
3
Task/HTTPS/0DESCRIPTION
Normal file
3
Task/HTTPS/0DESCRIPTION
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Print an HTTPS URL's content to the console. Checking the host certificate for validity is recommended. The client should not authenticate itself to the server — the webpage https://sourceforge.net/ supports that access policy — as that is the subject of other [[HTTPS request with authentication|tasks]].
|
||||
|
||||
Readers may wish to contrast with the [[HTTP Request]] task, and also the task on [[HTTPS request with authentication]].
|
||||
4
Task/HTTPS/1META.yaml
Normal file
4
Task/HTTPS/1META.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
category:
|
||||
- Networking and Web Interaction
|
||||
note: Programming environment operations
|
||||
8
Task/HTTPS/Ada/https.ada
Normal file
8
Task/HTTPS/Ada/https.ada
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
with AWS.Client;
|
||||
with AWS.Response;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
procedure GetHttps is
|
||||
begin
|
||||
Put_Line (AWS.Response.Message_Body (AWS.Client.Get (
|
||||
URL => "https://sourceforge.net/")));
|
||||
end GetHttps;
|
||||
7
Task/HTTPS/AutoHotkey/https.ahk
Normal file
7
Task/HTTPS/AutoHotkey/https.ahk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
URL := "https://sourceforge.net/"
|
||||
WININET_Init()
|
||||
msgbox % html := UrlGetContents(URL)
|
||||
WININET_UnInit()
|
||||
return
|
||||
#include urlgetcontents.ahk
|
||||
#include wininet.ahk
|
||||
1
Task/HTTPS/Batch-File/https.bat
Normal file
1
Task/HTTPS/Batch-File/https.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
curl.exe -k -s -L https://sourceforge.net/
|
||||
22
Task/HTTPS/C/https.c
Normal file
22
Task/HTTPS/C/https.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
char buffer[CURL_ERROR_SIZE];
|
||||
|
||||
if ((curl = curl_easy_init()) != NULL) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://sourceforge.net/");
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer);
|
||||
if (curl_easy_perform(curl) != CURLE_OK) {
|
||||
fprintf(stderr, "%s\n", buffer);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
2
Task/HTTPS/Clojure/https-1.clj
Normal file
2
Task/HTTPS/Clojure/https-1.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(use '[clojure.contrib.duck-streams :only (slurp*)])
|
||||
(print (slurp* "https://sourceforge.net"))
|
||||
1
Task/HTTPS/Clojure/https-2.clj
Normal file
1
Task/HTTPS/Clojure/https-2.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(print (slurp "https://sourceforge.net"))
|
||||
13
Task/HTTPS/Common-Lisp/https.lisp
Normal file
13
Task/HTTPS/Common-Lisp/https.lisp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(defun wget-drakma-string (url &optional (out *standard-output*))
|
||||
"Grab the body as a string, and write it to out."
|
||||
(write-string (drakma:http-request url) out))
|
||||
|
||||
(defun wget-drakma-stream (url &optional (out *standard-output*))
|
||||
"Grab the body as a stream, and write it to out."
|
||||
(loop with body = (drakma:http-request url :want-stream t)
|
||||
for line = (read-line body nil nil)
|
||||
while line do (write-line line)
|
||||
finally (close body)))
|
||||
|
||||
;; Use
|
||||
(wget-drakma-stream "https://sourceforge.net")
|
||||
23
Task/HTTPS/Delphi/https.delphi
Normal file
23
Task/HTTPS/Delphi/https.delphi
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
program ShowHTTPS;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses IdHttp, IdSSLOpenSSL;
|
||||
|
||||
var
|
||||
s: string;
|
||||
lHTTP: TIdHTTP;
|
||||
lIOHandler: TIdSSLIOHandlerSocketOpenSSL;
|
||||
begin
|
||||
lHTTP := TIdHTTP.Create(nil);
|
||||
lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
||||
try
|
||||
lHTTP.IOHandler := lIOHandler;
|
||||
lHTTP.HandleRedirects := True;
|
||||
s := lHTTP.Get('https://sourceforge.net/');
|
||||
Writeln(s);
|
||||
finally
|
||||
lHTTP.Free;
|
||||
lIOHandler.Free;
|
||||
end;
|
||||
end.
|
||||
10
Task/HTTPS/Erlang/https-1.erl
Normal file
10
Task/HTTPS/Erlang/https-1.erl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-module(main).
|
||||
-export([main/1]).
|
||||
|
||||
main([Url|[]]) ->
|
||||
inets:start(),
|
||||
ssl:start(),
|
||||
case http:request(get, {URL, []}, [{ssl,[{verify,0}]}], []) of
|
||||
{ok, {_V, _H, Body}} -> io:fwrite("~p~n",[Body]);
|
||||
{error, Res} -> io:fwrite("~p~n", [Res])
|
||||
end.
|
||||
12
Task/HTTPS/Erlang/https-2.erl
Normal file
12
Task/HTTPS/Erlang/https-2.erl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-module(main).
|
||||
-export([main/1]).
|
||||
|
||||
main([Url|[]]) ->
|
||||
inets:start(),
|
||||
ssl:start(),
|
||||
http:request(get, {Url, [] }, [{ssl,[{verify,0}]}], [{sync, false}]),
|
||||
receive
|
||||
{http, {_ReqId, Res}} -> io:fwrite("~p~n",[Res]);
|
||||
_Any -> io:fwrite("Error: ~p~n",[_Any])
|
||||
after 10000 -> io:fwrite("Timed out.~n",[])
|
||||
end.
|
||||
1
Task/HTTPS/Erlang/https-3.erl
Normal file
1
Task/HTTPS/Erlang/https-3.erl
Normal file
|
|
@ -0,0 +1 @@
|
|||
|escript ./req.erl https://sourceforge.net/
|
||||
16
Task/HTTPS/Go/https.go
Normal file
16
Task/HTTPS/Go/https.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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)
|
||||
}
|
||||
1
Task/HTTPS/Groovy/https.groovy
Normal file
1
Task/HTTPS/Groovy/https.groovy
Normal file
|
|
@ -0,0 +1 @@
|
|||
new URL("https://sourceforge.net").eachLine { println it }
|
||||
8
Task/HTTPS/Haskell/https.hs
Normal file
8
Task/HTTPS/Haskell/https.hs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/runhaskell
|
||||
|
||||
import Network.HTTP.Conduit
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import Network (withSocketsDo)
|
||||
|
||||
main = withSocketsDo
|
||||
$ simpleHttp "https://sourceforge.net/" >>= L.putStr
|
||||
6
Task/HTTPS/Ioke/https.ioke
Normal file
6
Task/HTTPS/Ioke/https.ioke
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
connection = URL new("https://sourceforge.net") openConnection
|
||||
scanner = Scanner new(connection getInputStream)
|
||||
|
||||
while(scanner hasNext,
|
||||
scanner next println
|
||||
)
|
||||
4
Task/HTTPS/J/https.j
Normal file
4
Task/HTTPS/J/https.j
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#page=: gethttp'https://sourceforge.net'
|
||||
0
|
||||
#page=: '--no-check-certificate' gethttp'https://sourceforge.net'
|
||||
900
|
||||
7
Task/HTTPS/Java/https.java
Normal file
7
Task/HTTPS/Java/https.java
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
URL url = new URL("https://sourceforge.net");
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
Scanner scanner = new Scanner(connection.getInputStream());
|
||||
|
||||
while (scanner.hasNext()) {
|
||||
System.out.println(scanner.next());
|
||||
}
|
||||
20
Task/HTTPS/LSL/https.lsl
Normal file
20
Task/HTTPS/LSL/https.lsl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
string sURL = "https://SourceForge.Net/";
|
||||
key kHttpRequestId;
|
||||
default {
|
||||
state_entry() {
|
||||
kHttpRequestId = llHTTPRequest(sURL, [], "");
|
||||
}
|
||||
http_response(key kRequestId, integer iStatus, list lMetaData, string sBody) {
|
||||
if(kRequestId==kHttpRequestId) {
|
||||
llOwnerSay("Status="+(string)iStatus);
|
||||
integer x = 0;
|
||||
for(x=0 ; x<llGetListLength(lMetaData) ; x++) {
|
||||
llOwnerSay("llList2String(lMetaData, "+(string)x+")="+llList2String(lMetaData, x));
|
||||
}
|
||||
list lBody = llParseString2List(sBody, ["\n"], []);
|
||||
for(x=0 ; x<llGetListLength(lBody) ; x++) {
|
||||
llOwnerSay("llList2String(lBody, "+(string)x+")="+llList2String(lBody, x));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Task/HTTPS/Mathematica/https.mathematica
Normal file
1
Task/HTTPS/Mathematica/https.mathematica
Normal file
|
|
@ -0,0 +1 @@
|
|||
content=Import["https://sourceforge.net", "HTML"]
|
||||
1
Task/HTTPS/PHP/https.php
Normal file
1
Task/HTTPS/PHP/https.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo file_get_contents('https://sourceforge.net');
|
||||
9
Task/HTTPS/Perl/https.pl
Normal file
9
Task/HTTPS/Perl/https.pl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use strict;
|
||||
use LWP::UserAgent;
|
||||
|
||||
my $url = 'https://www.rosettacode.org';
|
||||
my $response = LWP::UserAgent->new->get( $url );
|
||||
|
||||
$response->is_success or die "Failed to GET '$url': ", $response->status_line;
|
||||
|
||||
print $response->as_string;
|
||||
2
Task/HTTPS/PicoLisp/https.l
Normal file
2
Task/HTTPS/PicoLisp/https.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(in '(curl "https://sourceforge.net") # Open a pipe to 'curl'
|
||||
(out NIL (echo)) ) # Echo to standard output
|
||||
2
Task/HTTPS/Python/https-1.py
Normal file
2
Task/HTTPS/Python/https-1.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from urllib.request import urlopen
|
||||
print(urlopen('https://sourceforge.net/').read())
|
||||
2
Task/HTTPS/Python/https-2.py
Normal file
2
Task/HTTPS/Python/https-2.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from urllib2 import urlopen
|
||||
print urlopen('https://sourceforge.net/').read()
|
||||
2
Task/HTTPS/R/https-1.r
Normal file
2
Task/HTTPS/R/https-1.r
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
library(RCurl)
|
||||
webpage <- getURL("https://sourceforge.net/", .opts=list(followlocation=TRUE, ssl.verifyhost=FALSE, ssl.verifypeer=FALSE))
|
||||
2
Task/HTTPS/R/https-2.r
Normal file
2
Task/HTTPS/R/https-2.r
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
wp <- readLines(tc <- textConnection(webpage))
|
||||
close(tc)
|
||||
2
Task/HTTPS/R/https-3.r
Normal file
2
Task/HTTPS/R/https-3.r
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
pagetree <- htmlTreeParse(wp)
|
||||
pagetree$children$html
|
||||
5
Task/HTTPS/Racket/https.rkt
Normal file
5
Task/HTTPS/Racket/https.rkt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#lang racket
|
||||
(require net/url)
|
||||
(copy-port (get-pure-port (string->url "https://www.google.com")
|
||||
#:redirections 100)
|
||||
(current-output-port))
|
||||
15
Task/HTTPS/Ruby/https.rb
Normal file
15
Task/HTTPS/Ruby/https.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require 'net/https'
|
||||
require 'uri'
|
||||
require 'pp'
|
||||
|
||||
uri = URI.parse('https://sourceforge.net')
|
||||
http = Net::HTTP.new(uri.host,uri.port)
|
||||
http.use_ssl = true
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
|
||||
http.start do
|
||||
content = http.get("/")
|
||||
p [content.code, content.message]
|
||||
pp content.to_hash
|
||||
puts content.body
|
||||
end
|
||||
16
Task/HTTPS/Tcl/https.tcl
Normal file
16
Task/HTTPS/Tcl/https.tcl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package require http
|
||||
package require tls
|
||||
|
||||
# Tell the http package what to do with “https:” URLs.
|
||||
#
|
||||
# First argument is the protocol name, second the default port, and
|
||||
# third the connection builder command
|
||||
http::register "https" 443 ::tls::socket
|
||||
|
||||
# Make a secure connection, which is almost identical to normal
|
||||
# connections except for the different protocol in the URL.
|
||||
set token [http::geturl "https://sourceforge.net/"]
|
||||
|
||||
# Now as for conventional use of the “http” package
|
||||
puts [http::data $token]
|
||||
http::cleanup $token
|
||||
Loading…
Add table
Add a link
Reference in a new issue