Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

5
Task/HTTP/00-META.yaml Normal file
View file

@ -0,0 +1,5 @@
---
category:
- Networking and Web Interaction
from: http://rosettacode.org/wiki/HTTP
note: Programming environment operations

6
Task/HTTP/00-TASK.txt Normal file
View file

@ -0,0 +1,6 @@
;Task:
Access and print a [[wp:Uniform Resource Locator|URL]]'s content (the located resource) to the console.
There is a separate task for [[HTTPS Request]]s.
<br><br>

1
Task/HTTP/8th/http.8th Normal file
View file

@ -0,0 +1 @@
"http://www.rosettacode.org" net:get drop >s .

35
Task/HTTP/ABAP/http.abap Normal file
View file

@ -0,0 +1,35 @@
report z_http.
cl_http_client=>create_by_url(
exporting
url = `http://rosettacode.org/robots.txt`
importing
client = data(http_client)
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4 ).
if sy-subrc <> 0.
data(error_message) = switch string( sy-subrc
when 1 then `argument_not_found`
when 2 then `plugin_not_active`
when 3 then `internal_error`
when 4 then `other error` ).
write error_message.
exit.
endif.
data(rest_http_client) = cast if_rest_client( new cl_rest_http_client( http_client ) ).
rest_http_client->get( ).
data(response_string) = rest_http_client->get_response_entity( )->get_string_data( ).
split response_string at cl_abap_char_utilities=>newline into table data(output_table).
loop at output_table assigning field-symbol(<output_line>).
write / <output_line>.
endloop.

View file

@ -0,0 +1,29 @@
STRING domain="rosettacode.org";
STRING page="wiki/Main_Page";
STRING re success="^HTTP/[0-9.]* 200";
STRING re result description="^HTTP/[0-9.]* [0-9]+ [a-zA-Z ]*";
STRING re doctype ="\s\s<!DOCTYPE html PUBLIC ""[^>]+"">\s+";
PROC html page = (REF STRING page) BOOL: (
BOOL out=grep in string(re success, page, NIL, NIL) = 0;
IF INT start, end;
grep in string(re result description, page, start, end) = 0
THEN
page:=page[end+1:];
IF grep in string(re doctype, page, start, end) = 0
THEN page:=page[start+2:]
ELSE print ("unknown format retrieving page")
FI
ELSE print ("unknown error retrieving page")
FI;
out
);
IF STRING reply;
INT rc =
http content (reply, domain, "http://"+domain+"/"+page, 0);
rc = 0 AND html page (reply)
THEN print (reply)
ELSE print (strerror (rc))
FI

20
Task/HTTP/AWK/http.awk Normal file
View file

@ -0,0 +1,20 @@
BEGIN {
site="en.wikipedia.org"
path="/wiki/"
name="Rosetta_Code"
server = "/inet/tcp/0/" site "/80"
print "GET " path name " HTTP/1.0" |& server
print "Host: " site |& server
print "\r\n\r\n" |& server
while ( (server |& getline fish) > 0 ) {
if ( ++scale == 1 )
ship = fish
else
ship = ship "\n" fish
}
close(server)
print ship
}

View file

@ -0,0 +1,21 @@
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.*;
public class RequestExample extends Sprite
{
public function RequestExample()
{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadComplete);
loader.load(new URLRequest("http://www.rosettacode.org"));
}
private function loadComplete(evt:Event):void
{
trace(evt.target.data);
}
}
}

9
Task/HTTP/Ada/http.ada Normal file
View file

@ -0,0 +1,9 @@
with Ada.Text_IO; use Ada.Text_IO;
with AWS.Client;
with AWS.Response;
procedure HTTP_Request is
begin
Put_Line (AWS.Response.Message_Body (AWS.Client.Get (URL => "http://www.rosettacode.org")));
end HTTP_Request;

View file

@ -0,0 +1,6 @@
#include <hopper.h>
main:
s=`curl -s -L https://rosettacode.org/wiki/HTTP`
{s}len, lenght=0, mov(lenght)
{"Size = ",lenght,"\nContent = \n",s}println
exit(0)

View file

@ -0,0 +1 @@
print read "http://rosettacode.org"

View file

@ -0,0 +1,2 @@
UrlDownloadToFile, http://rosettacode.org, url.html
Run, cmd /k type url.html

View file

@ -0,0 +1,9 @@
SYS "LoadLibrary", "URLMON.DLL" TO urlmon%
SYS "GetProcAddress", urlmon%, "URLDownloadToFileA" TO URLDownloadToFile
url$ = "http://www.bbcbasic.co.uk/aboutus.html"
file$ = @tmp$ + "rosetta.tmp"
SYS URLDownloadToFile, 0, url$, file$, 0, 0 TO fail%
IF fail% ERROR 100, "File download failed"
OSCLI "TYPE """ + file$ + """"

View file

@ -0,0 +1,17 @@
'
' Read and display a website
'
IF AMOUNT(ARGUMENT$) = 1 THEN
website$ = "www.basic-converter.org"
ELSE
website$ = TOKEN$(ARGUMENT$, 2)
ENDIF
OPEN website$ & ":80" FOR NETWORK AS mynet
SEND "GET / HTTP/1.1\r\nHost: " & website$ & "\r\n\r\n" TO mynet
REPEAT
RECEIVE dat$ FROM mynet
total$ = total$ & dat$
UNTIL ISFALSE(WAIT(mynet, 500))
CLOSE NETWORK mynet
PRINT total$

View file

@ -0,0 +1 @@
curl.exe -s -L http://rosettacode.org/

View file

@ -0,0 +1 @@
$httpExt.ExecRemote("www.tabasoft.it")

38
Task/HTTP/C++/http-1.cpp Normal file
View file

@ -0,0 +1,38 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iostream>
int main() {
WSADATA wsaData;
WSAStartup( MAKEWORD( 2, 2 ), &wsaData );
addrinfo *result = NULL;
addrinfo hints;
ZeroMemory( &hints, sizeof( hints ) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
getaddrinfo( "74.125.45.100", "80", &hints, &result ); // http://www.google.com
SOCKET s = socket( result->ai_family, result->ai_socktype, result->ai_protocol );
connect( s, result->ai_addr, (int)result->ai_addrlen );
freeaddrinfo( result );
send( s, "GET / HTTP/1.0\n\n", 16, 0 );
char buffer[512];
int bytes;
do {
bytes = recv( s, buffer, 512, 0 );
if ( bytes > 0 )
std::cout.write(buffer, bytes);
} while ( bytes > 0 );
return 0;
}

8
Task/HTTP/C++/http-2.cpp Normal file
View file

@ -0,0 +1,8 @@
#include <Web/Web.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Cout() << HttpClient("www.rosettacode.org").ExecuteRedirect();
}

13
Task/HTTP/C-sharp/http.cs Normal file
View file

@ -0,0 +1,13 @@
using System;
using System.Text;
using System.Net;
class Program
{
static void Main(string[] args)
{
WebClient wc = new WebClient();
string content = wc.DownloadString("http://www.google.com");
Console.WriteLine(content);
}
}

22
Task/HTTP/C/http.c Normal file
View 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, "http://www.rosettacode.org/");
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;
}

View file

@ -0,0 +1,292 @@
COBOL >>SOURCE FORMAT IS FIXED
identification division.
program-id. curl-rosetta.
environment division.
configuration section.
repository.
function read-url
function all intrinsic.
data division.
working-storage section.
copy "gccurlsym.cpy".
01 web-page pic x(16777216).
01 curl-status usage binary-long.
01 cli pic x(7) external.
88 helping values "-h", "-help", "help", spaces.
88 displaying value "display".
88 summarizing value "summary".
*> ***************************************************************
procedure division.
accept cli from command-line
if helping then
display "./curl-rosetta [help|display|summary]"
goback
end-if
*>
*> Read a web resource into fixed ram.
*> Caller is in charge of sizing the buffer,
*> (or getting trickier with the write callback)
*> Pass URL and working-storage variable,
*> get back libcURL error code or 0 for success
move read-url("http://www.rosettacode.org", web-page)
to curl-status
perform check
perform show
goback.
*> ***************************************************************
*> Now tesing the result, relying on the gccurlsym
*> GnuCOBOL Curl Symbol copy book
check.
if curl-status not equal zero then
display
curl-status " "
CURLEMSG(curl-status) upon syserr
end-if
.
*> And display the page
show.
if summarizing then
display "Length: " stored-char-length(web-page)
end-if
if displaying then
display trim(web-page trailing) with no advancing
end-if
.
REPLACE ALSO ==:EXCEPTION-HANDLERS:== BY
==
*> informational warnings and abends
soft-exception.
display space upon syserr
display "--Exception Report-- " upon syserr
display "Time of exception: " current-date upon syserr
display "Module: " module-id upon syserr
display "Module-path: " module-path upon syserr
display "Module-source: " module-source upon syserr
display "Exception-file: " exception-file upon syserr
display "Exception-status: " exception-status upon syserr
display "Exception-location: " exception-location upon syserr
display "Exception-statement: " exception-statement upon syserr
.
hard-exception.
perform soft-exception
stop run returning 127
.
==.
end program curl-rosetta.
*> ***************************************************************
*> ***************************************************************
*>
*> The function hiding all the curl details
*>
*> Purpose: Call libcURL and read into memory
*> ***************************************************************
identification division.
function-id. read-url.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
copy "gccurlsym.cpy".
replace also ==:CALL-EXCEPTION:== by
==
on exception
perform hard-exception
==.
01 curl-handle usage pointer.
01 callback-handle usage procedure-pointer.
01 memory-block.
05 memory-address usage pointer sync.
05 memory-size usage binary-long sync.
05 running-total usage binary-long sync.
01 curl-result usage binary-long.
01 cli pic x(7) external.
88 helping values "-h", "-help", "help", spaces.
88 displaying value "display".
88 summarizing value "summary".
linkage section.
01 url pic x any length.
01 buffer pic x any length.
01 curl-status usage binary-long.
*> ***************************************************************
procedure division using url buffer returning curl-status.
if displaying or summarizing then
display "Read: " url upon syserr
end-if
*> initialize libcurl, hint at missing library if need be
call "curl_global_init" using by value CURL_GLOBAL_ALL
on exception
display
"need libcurl, link with -lcurl" upon syserr
stop run returning 1
end-call
*> initialize handle
call "curl_easy_init" returning curl-handle
:CALL-EXCEPTION:
end-call
if curl-handle equal NULL then
display "no curl handle" upon syserr
stop run returning 1
end-if
*> Set the URL
call "curl_easy_setopt" using
by value curl-handle
by value CURLOPT_URL
by reference concatenate(trim(url trailing), x"00")
:CALL-EXCEPTION:
end-call
*> follow all redirects
call "curl_easy_setopt" using
by value curl-handle
by value CURLOPT_FOLLOWLOCATION
by value 1
:CALL-EXCEPTION:
end-call
*> set the call back to write to memory
set callback-handle to address of entry "curl-write-callback"
call "curl_easy_setopt" using
by value curl-handle
by value CURLOPT_WRITEFUNCTION
by value callback-handle
:CALL-EXCEPTION:
end-call
*> set the curl handle data handling structure
set memory-address to address of buffer
move length(buffer) to memory-size
move 1 to running-total
call "curl_easy_setopt" using
by value curl-handle
by value CURLOPT_WRITEDATA
by value address of memory-block
:CALL-EXCEPTION:
end-call
*> some servers demand an agent
call "curl_easy_setopt" using
by value curl-handle
by value CURLOPT_USERAGENT
by reference concatenate("libcurl-agent/1.0", x"00")
:CALL-EXCEPTION:
end-call
*> let curl do all the hard work
call "curl_easy_perform" using
by value curl-handle
returning curl-result
:CALL-EXCEPTION:
end-call
*> the call back will handle filling ram, return the result code
move curl-result to curl-status
*> curl clean up, more important if testing cookies
call "curl_easy_cleanup" using
by value curl-handle
returning omitted
:CALL-EXCEPTION:
end-call
goback.
:EXCEPTION-HANDLERS:
end function read-url.
*> ***************************************************************
*> ***************************************************************
*> Supporting libcurl callback
identification division.
program-id. curl-write-callback.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 real-size usage binary-long.
*> libcURL will pass a pointer to this structure in the callback
01 memory-block based.
05 memory-address usage pointer sync.
05 memory-size usage binary-long sync.
05 running-total usage binary-long sync.
01 content-buffer pic x(65536) based.
01 web-space pic x(16777216) based.
01 left-over usage binary-long.
linkage section.
01 contents usage pointer.
01 element-size usage binary-long.
01 element-count usage binary-long.
01 memory-structure usage pointer.
*> ***************************************************************
procedure division
using
by value contents
by value element-size
by value element-count
by value memory-structure
returning real-size.
set address of memory-block to memory-structure
compute real-size = element-size * element-count end-compute
*> Fence off the end of buffer
compute
left-over = memory-size - running-total
end-compute
if left-over > 0 and < real-size then
move left-over to real-size
end-if
*> if there is more buffer, and data not zero length
if (left-over > 0) and (real-size > 1) then
set address of content-buffer to contents
set address of web-space to memory-address
move content-buffer(1:real-size)
to web-space(running-total:real-size)
add real-size to running-total
else
display "curl buffer sizing problem" upon syserr
end-if
goback.
end program curl-write-callback.

View file

@ -0,0 +1,192 @@
*> manifest constants for libcurl
*> Usage: COPY occurlsym inside data division
*> Taken from include/curl/curl.h 2013-12-19
*> Functional enums
01 CURL_MAX_HTTP_HEADER CONSTANT AS 102400.
78 CURL_GLOBAL_ALL VALUE 3.
78 CURLOPT_FOLLOWLOCATION VALUE 52.
78 CURLOPT_WRITEDATA VALUE 10001.
78 CURLOPT_URL VALUE 10002.
78 CURLOPT_USERAGENT VALUE 10018.
78 CURLOPT_WRITEFUNCTION VALUE 20011.
78 CURLOPT_COOKIEFILE VALUE 10031.
78 CURLOPT_COOKIEJAR VALUE 10082.
78 CURLOPT_COOKIELIST VALUE 10135.
*> Informationals
78 CURLINFO_COOKIELIST VALUE 4194332.
*> Result codes
78 CURLE_OK VALUE 0.
*> Error codes
78 CURLE_UNSUPPORTED_PROTOCOL VALUE 1.
78 CURLE_FAILED_INIT VALUE 2.
78 CURLE_URL_MALFORMAT VALUE 3.
78 CURLE_OBSOLETE4 VALUE 4.
78 CURLE_COULDNT_RESOLVE_PROXY VALUE 5.
78 CURLE_COULDNT_RESOLVE_HOST VALUE 6.
78 CURLE_COULDNT_CONNECT VALUE 7.
78 CURLE_FTP_WEIRD_SERVER_REPLY VALUE 8.
78 CURLE_REMOTE_ACCESS_DENIED VALUE 9.
78 CURLE_OBSOLETE10 VALUE 10.
78 CURLE_FTP_WEIRD_PASS_REPLY VALUE 11.
78 CURLE_OBSOLETE12 VALUE 12.
78 CURLE_FTP_WEIRD_PASV_REPLY VALUE 13.
78 CURLE_FTP_WEIRD_227_FORMAT VALUE 14.
78 CURLE_FTP_CANT_GET_HOST VALUE 15.
78 CURLE_OBSOLETE16 VALUE 16.
78 CURLE_FTP_COULDNT_SET_TYPE VALUE 17.
78 CURLE_PARTIAL_FILE VALUE 18.
78 CURLE_FTP_COULDNT_RETR_FILE VALUE 19.
78 CURLE_OBSOLETE20 VALUE 20.
78 CURLE_QUOTE_ERROR VALUE 21.
78 CURLE_HTTP_RETURNED_ERROR VALUE 22.
78 CURLE_WRITE_ERROR VALUE 23.
78 CURLE_OBSOLETE24 VALUE 24.
78 CURLE_UPLOAD_FAILED VALUE 25.
78 CURLE_READ_ERROR VALUE 26.
78 CURLE_OUT_OF_MEMORY VALUE 27.
78 CURLE_OPERATION_TIMEDOUT VALUE 28.
78 CURLE_OBSOLETE29 VALUE 29.
78 CURLE_FTP_PORT_FAILED VALUE 30.
78 CURLE_FTP_COULDNT_USE_REST VALUE 31.
78 CURLE_OBSOLETE32 VALUE 32.
78 CURLE_RANGE_ERROR VALUE 33.
78 CURLE_HTTP_POST_ERROR VALUE 34.
78 CURLE_SSL_CONNECT_ERROR VALUE 35.
78 CURLE_BAD_DOWNLOAD_RESUME VALUE 36.
78 CURLE_FILE_COULDNT_READ_FILE VALUE 37.
78 CURLE_LDAP_CANNOT_BIND VALUE 38.
78 CURLE_LDAP_SEARCH_FAILED VALUE 39.
78 CURLE_OBSOLETE40 VALUE 40.
78 CURLE_FUNCTION_NOT_FOUND VALUE 41.
78 CURLE_ABORTED_BY_CALLBACK VALUE 42.
78 CURLE_BAD_FUNCTION_ARGUMENT VALUE 43.
78 CURLE_OBSOLETE44 VALUE 44.
78 CURLE_INTERFACE_FAILED VALUE 45.
78 CURLE_OBSOLETE46 VALUE 46.
78 CURLE_TOO_MANY_REDIRECTS VALUE 47.
78 CURLE_UNKNOWN_TELNET_OPTION VALUE 48.
78 CURLE_TELNET_OPTION_SYNTAX VALUE 49.
78 CURLE_OBSOLETE50 VALUE 50.
78 CURLE_PEER_FAILED_VERIFICATION VALUE 51.
78 CURLE_GOT_NOTHING VALUE 52.
78 CURLE_SSL_ENGINE_NOTFOUND VALUE 53.
78 CURLE_SSL_ENGINE_SETFAILED VALUE 54.
78 CURLE_SEND_ERROR VALUE 55.
78 CURLE_RECV_ERROR VALUE 56.
78 CURLE_OBSOLETE57 VALUE 57.
78 CURLE_SSL_CERTPROBLEM VALUE 58.
78 CURLE_SSL_CIPHER VALUE 59.
78 CURLE_SSL_CACERT VALUE 60.
78 CURLE_BAD_CONTENT_ENCODING VALUE 61.
78 CURLE_LDAP_INVALID_URL VALUE 62.
78 CURLE_FILESIZE_EXCEEDED VALUE 63.
78 CURLE_USE_SSL_FAILED VALUE 64.
78 CURLE_SEND_FAIL_REWIND VALUE 65.
78 CURLE_SSL_ENGINE_INITFAILED VALUE 66.
78 CURLE_LOGIN_DENIED VALUE 67.
78 CURLE_TFTP_NOTFOUND VALUE 68.
78 CURLE_TFTP_PERM VALUE 69.
78 CURLE_REMOTE_DISK_FULL VALUE 70.
78 CURLE_TFTP_ILLEGAL VALUE 71.
78 CURLE_TFTP_UNKNOWNID VALUE 72.
78 CURLE_REMOTE_FILE_EXISTS VALUE 73.
78 CURLE_TFTP_NOSUCHUSER VALUE 74.
78 CURLE_CONV_FAILED VALUE 75.
78 CURLE_CONV_REQD VALUE 76.
78 CURLE_SSL_CACERT_BADFILE VALUE 77.
78 CURLE_REMOTE_FILE_NOT_FOUND VALUE 78.
78 CURLE_SSH VALUE 79.
78 CURLE_SSL_SHUTDOWN_FAILED VALUE 80.
78 CURLE_AGAIN VALUE 81.
*> Error strings
01 LIBCURL_ERRORS.
02 CURLEVALUES.
03 FILLER PIC X(30) VALUE "CURLE_UNSUPPORTED_PROTOCOL ".
03 FILLER PIC X(30) VALUE "CURLE_FAILED_INIT ".
03 FILLER PIC X(30) VALUE "CURLE_URL_MALFORMAT ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE4 ".
03 FILLER PIC X(30) VALUE "CURLE_COULDNT_RESOLVE_PROXY ".
03 FILLER PIC X(30) VALUE "CURLE_COULDNT_RESOLVE_HOST ".
03 FILLER PIC X(30) VALUE "CURLE_COULDNT_CONNECT ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_WEIRD_SERVER_REPLY ".
03 FILLER PIC X(30) VALUE "CURLE_REMOTE_ACCESS_DENIED ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE10 ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_WEIRD_PASS_REPLY ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE12 ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_WEIRD_PASV_REPLY ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_WEIRD_227_FORMAT ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_CANT_GET_HOST ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE16 ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_COULDNT_SET_TYPE ".
03 FILLER PIC X(30) VALUE "CURLE_PARTIAL_FILE ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_COULDNT_RETR_FILE ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE20 ".
03 FILLER PIC X(30) VALUE "CURLE_QUOTE_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_HTTP_RETURNED_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_WRITE_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE24 ".
03 FILLER PIC X(30) VALUE "CURLE_UPLOAD_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_READ_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_OUT_OF_MEMORY ".
03 FILLER PIC X(30) VALUE "CURLE_OPERATION_TIMEDOUT ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE29 ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_PORT_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_FTP_COULDNT_USE_REST ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE32 ".
03 FILLER PIC X(30) VALUE "CURLE_RANGE_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_HTTP_POST_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_CONNECT_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_BAD_DOWNLOAD_RESUME ".
03 FILLER PIC X(30) VALUE "CURLE_FILE_COULDNT_READ_FILE ".
03 FILLER PIC X(30) VALUE "CURLE_LDAP_CANNOT_BIND ".
03 FILLER PIC X(30) VALUE "CURLE_LDAP_SEARCH_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE40 ".
03 FILLER PIC X(30) VALUE "CURLE_FUNCTION_NOT_FOUND ".
03 FILLER PIC X(30) VALUE "CURLE_ABORTED_BY_CALLBACK ".
03 FILLER PIC X(30) VALUE "CURLE_BAD_FUNCTION_ARGUMENT ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE44 ".
03 FILLER PIC X(30) VALUE "CURLE_INTERFACE_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE46 ".
03 FILLER PIC X(30) VALUE "CURLE_TOO_MANY_REDIRECTS ".
03 FILLER PIC X(30) VALUE "CURLE_UNKNOWN_TELNET_OPTION ".
03 FILLER PIC X(30) VALUE "CURLE_TELNET_OPTION_SYNTAX ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE50 ".
03 FILLER PIC X(30) VALUE "CURLE_PEER_FAILED_VERIFICATION".
03 FILLER PIC X(30) VALUE "CURLE_GOT_NOTHING ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_ENGINE_NOTFOUND ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_ENGINE_SETFAILED ".
03 FILLER PIC X(30) VALUE "CURLE_SEND_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_RECV_ERROR ".
03 FILLER PIC X(30) VALUE "CURLE_OBSOLETE57 ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_CERTPROBLEM ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_CIPHER ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_CACERT ".
03 FILLER PIC X(30) VALUE "CURLE_BAD_CONTENT_ENCODING ".
03 FILLER PIC X(30) VALUE "CURLE_LDAP_INVALID_URL ".
03 FILLER PIC X(30) VALUE "CURLE_FILESIZE_EXCEEDED ".
03 FILLER PIC X(30) VALUE "CURLE_USE_SSL_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_SEND_FAIL_REWIND ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_ENGINE_INITFAILED ".
03 FILLER PIC X(30) VALUE "CURLE_LOGIN_DENIED ".
03 FILLER PIC X(30) VALUE "CURLE_TFTP_NOTFOUND ".
03 FILLER PIC X(30) VALUE "CURLE_TFTP_PERM ".
03 FILLER PIC X(30) VALUE "CURLE_REMOTE_DISK_FULL ".
03 FILLER PIC X(30) VALUE "CURLE_TFTP_ILLEGAL ".
03 FILLER PIC X(30) VALUE "CURLE_TFTP_UNKNOWNID ".
03 FILLER PIC X(30) VALUE "CURLE_REMOTE_FILE_EXISTS ".
03 FILLER PIC X(30) VALUE "CURLE_TFTP_NOSUCHUSER ".
03 FILLER PIC X(30) VALUE "CURLE_CONV_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_CONV_REQD ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_CACERT_BADFILE ".
03 FILLER PIC X(30) VALUE "CURLE_REMOTE_FILE_NOT_FOUND ".
03 FILLER PIC X(30) VALUE "CURLE_SSH ".
03 FILLER PIC X(30) VALUE "CURLE_SSL_SHUTDOWN_FAILED ".
03 FILLER PIC X(30) VALUE "CURLE_AGAIN ".
01 FILLER REDEFINES LIBCURL_ERRORS.
02 CURLEMSG OCCURS 81 TIMES PIC X(30).

View file

@ -0,0 +1,6 @@
(defn get-http [url]
(let [sc (java.util.Scanner.
(.openStream (java.net.URL. url)))]
(while (.hasNext sc)
(println (.nextLine sc)))))
(get-http "http://www.rosettacode.org")

View file

@ -0,0 +1,4 @@
(ns example
(:use [clojure.contrib.http.agent :only (string http-agent)]))
(println (string (http-agent "http://www.rosettacode.org/")))

View file

@ -0,0 +1 @@
(print (slurp "http://www.rosettacode.org/"))

View file

@ -0,0 +1,2 @@
<cfhttp url="http://www.rosettacode.org" result="result">
<cfoutput>#result.FileContent#</cfoutput>

View file

@ -0,0 +1,5 @@
(defun wget-clisp (url)
(ext:with-http-input (stream url)
(loop for line = (read-line stream nil nil)
while line
do (format t "~a~%" line))))

View file

@ -0,0 +1,10 @@
(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 out)
finally (close body)))

View file

@ -0,0 +1 @@
(format t "~a~%" (nth-value 0 (dex:get "http://www.w3.org/")))

View file

@ -0,0 +1,3 @@
require "http/client"
HTTP::Client.get("http://google.com")

4
Task/HTTP/D/http-1.d Normal file
View file

@ -0,0 +1,4 @@
void main() {
import std.stdio, std.net.curl;
writeln(get("http://google.com"));
}

6
Task/HTTP/D/http-2.d Normal file
View file

@ -0,0 +1,6 @@
import tango.io.Console;
import tango.net.http.HttpGet;
void main() {
Cout.stream.copy( (new HttpGet("http://google.com")).open );
}

10
Task/HTTP/D/http-3.d Normal file
View file

@ -0,0 +1,10 @@
import tango.io.Console;
import tango.net.InternetAddress;
import tango.net.device.Socket;
void main() {
auto site = new Socket;
site.connect (new InternetAddress("google.com",80)).write ("GET / HTTP/1.0\n\n");
Cout.stream.copy (site);
}

8
Task/HTTP/Dart/http.dart Normal file
View file

@ -0,0 +1,8 @@
import 'dart:io';
void main(){
var url = 'http://rosettacode.org';
var client = new HttpClient();
client.getUrl(Uri.parse(url))
.then((HttpClientRequest request) => request.close())
.then((HttpClientResponse response) => response.pipe(stdout));
}

View file

@ -0,0 +1,43 @@
program HTTP;
{$APPTYPE CONSOLE}
{$DEFINE DEBUG}
uses
Classes,
httpsend; // Synapse httpsend class
var
Response: TStrings;
HTTPObj: THTTPSend;
begin
HTTPObj := THTTPSend.Create;
try
{ Stringlist object to capture HTML returned
from URL }
Response := TStringList.Create;
try
if HTTPObj.HTTPMethod('GET','http://www.mgis.uk.com') then
begin
{ Load HTTP Document into Stringlist }
Response.LoadFromStream(HTTPObj.Document);
{ Write the response to the console window }
Writeln(Response.Text);
end
else
Writeln('Error retrieving data');
finally
Response.Free;
end;
finally
HTTPObj.Free;
end;
// Keep console window open
Readln;
end.

View file

@ -0,0 +1,19 @@
program ShowHTTP;
{$APPTYPE CONSOLE}
uses IdHttp;
var
s: string;
lHTTP: TIdHTTP;
begin
lHTTP := TIdHTTP.Create(nil);
try
lHTTP.HandleRedirects := True;
s := lHTTP.Get('http://www.rosettacode.org');
Writeln(s);
finally
lHTTP.Free;
end;
end.

View file

@ -0,0 +1,4 @@
select "http"
select "std"
http("http://www.rosettacode.org", ::echo)

3
Task/HTTP/E/http.e Normal file
View file

@ -0,0 +1,3 @@
when (def t := <http://www.rosettacode.org> <- getText()) -> {
println(t)
}

View file

@ -0,0 +1,4 @@
;; asynchronous call back definition
(define (success name text) (writeln 'Loaded name) (writeln text))
;;
(file->string success "http://www.google.com")

View file

@ -0,0 +1,5 @@
(let ((buffer (url-retrieve-synchronously "http://www.rosettacode.org")))
(unwind-protect
(with-current-buffer buffer
(message "%s" (buffer-substring url-http-end-of-headers (point-max))))
(kill-buffer buffer)))

View file

@ -0,0 +1,3 @@
(url-retrieve "http://www.rosettacode.org"
(lambda (_status)
(message "%s" (buffer-substring url-http-end-of-headers (point-max)))))

View file

@ -0,0 +1,9 @@
-module(main).
-export([main/1]).
main([Url|[]]) ->
inets:start(),
case http:request(Url) of
{ok, {_V, _H, Body}} -> io:fwrite("~p~n",[Body]);
{error, Res} -> io:fwrite("~p~n", [Res])
end.

View file

@ -0,0 +1,11 @@
-module(main).
-export([main/1]).
main([Url|[]]) ->
inets:start(),
http:request(get, {Url, [] }, [], [{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.

View file

@ -0,0 +1 @@
|escript ./req.erl http://www.rosettacode.org

View file

@ -0,0 +1,5 @@
let wget (url : string) =
use c = new System.Net.WebClient()
c.DownloadString(url)
printfn "%s" (wget "http://www.rosettacode.org/")

View file

@ -0,0 +1,15 @@
open System.Net
open System.IO
let wgetAsync url =
async { let request = WebRequest.Create (url:string)
use! response = request.AsyncGetResponse()
use responseStream = response.GetResponseStream()
use reader = new StreamReader(responseStream)
return reader.ReadToEnd() }
let urls = ["http://www.rosettacode.org/"; "http://www.yahoo.com/"; "http://www.google.com/"]
let content = urls
|> List.map wgetAsync
|> Async.Parallel
|> Async.RunSynchronously

View file

@ -0,0 +1,2 @@
USE: http.client
"http://www.rosettacode.org" http-get nip print

6
Task/HTTP/Forth/http.fth Normal file
View file

@ -0,0 +1,6 @@
include unix/socket.fs
s" localhost" 80 open-socket
dup s\" GET / HTTP/1.0\n\n" rot write-socket
dup pad 8092 read-socket type
close-socket

View file

@ -0,0 +1,9 @@
Dim As String urlfile
urlfile="start http://rosettacode.org/wiki/Main_Page"
Print urlfile
Shell(urlfile)
Print !"\n--- pulsa RETURN para continuar ---"
Sleep

View file

@ -0,0 +1 @@
curl -s -L http://rosettacode.org/

View file

@ -0,0 +1 @@
lynx -source http://rosettacode.org/

View file

@ -0,0 +1 @@
wget -O - -q http://rosettacode.org/

View file

@ -0,0 +1 @@
lftp -c "cat http://rosettacode.org/"

View file

@ -0,0 +1 @@
ftp -o - http://rosettacode.org ^ /dev/null

View file

@ -0,0 +1 @@
print[read["http://frinklang.org/"]]

1
Task/HTTP/GML/http-1.gml Normal file
View file

@ -0,0 +1 @@
get = http_get("http://www.rosettacode.org/");

4
Task/HTTP/GML/http-2.gml Normal file
View file

@ -0,0 +1,4 @@
if (ds_map_find_value(async_load,"id") == get)
{
show_message_async(ds_map_find_value(async_load,"result"));
}

View file

@ -0,0 +1,3 @@
Start,Programs,Applications,Mozilla Firefox,Inputbox:address bar>www.rosettacode.org,Button:Go,
Click:Area:browser window,Type:[Control A],[Control C],Start,Programs,Accessories,Notepad,
Menu:Edit,Paste

View file

@ -0,0 +1,5 @@
#listix#
<main>
LOOP, TEXT FILE, http://www.rosettacode.org
, BODY, @<value>

16
Task/HTTP/Go/http.go Normal file
View file

@ -0,0 +1,16 @@
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
r, err := http.Get("http://rosettacode.org/robots.txt")
if err != nil {
log.Fatalln(err)
}
io.Copy(os.Stdout, r.Body)
}

View file

@ -0,0 +1 @@
new URL("http://www.rosettacode.org").eachLine { println it }

View file

@ -0,0 +1 @@
echo http("http://www.rosettacode.org");

10
Task/HTTP/Haskell/http.hs Normal file
View file

@ -0,0 +1,10 @@
import Network.Browser
import Network.HTTP
import Network.URI
main = do
rsp <- Network.Browser.browse $ do
setAllowRedirects True
setOutHandler $ const (return ())
request $ getRequest "http://www.rosettacode.org/"
putStrLn $ rspBody $ snd rsp

View file

@ -0,0 +1,19 @@
link cfunc
procedure main(arglist)
get(arglist[1])
end
procedure get(url)
local f, host, port, path
url ? {
="http://" | ="HTTP://"
host := tab(upto(':/') | 0)
if not (=":" & (port := integer(tab(upto('/'))))) then port := 80
if pos(0) then path := "/" else path := tab(0)
}
write(host)
write(path)
f := tconnect(host, port) | stop("Unable to connect")
writes(f, "GET ", path | "/" ," HTTP/1.0\r\n\r\n")
while write(read(f))
end

View file

@ -0,0 +1 @@
|icon req.icn http://www.rosettacode.org

2
Task/HTTP/J/http.j Normal file
View file

@ -0,0 +1,2 @@
require'web/gethttp'
gethttp 'http://www.rosettacode.org'

View file

@ -0,0 +1,6 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

View file

@ -0,0 +1,8 @@
void printContent(String address) throws URISyntaxException, IOException {
URL url = new URI(address).toURL();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
String line;
while ((line = reader.readLine()) != null)
System.out.println(line);
}
}

View file

@ -0,0 +1,19 @@
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.Charset;
public class Main {
public static void main(String[] args) {
var request = HttpRequest.newBuilder(URI.create("https://www.rosettacode.org"))
.GET()
.build();
HttpClient.newHttpClient()
.sendAsync(request, HttpResponse.BodyHandlers.ofString(Charset.defaultCharset()))
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
}
}

View file

@ -0,0 +1,8 @@
import org.apache.commons.io.IOUtils;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
IOUtils.copy(new URL("http://rosettacode.org").openStream(),System.out);
}
}

View file

@ -0,0 +1,7 @@
var req = new XMLHttpRequest();
req.onload = function() {
console.log(this.responseText);
};
req.open('get', 'http://rosettacode.org', true);
req.send()

View file

@ -0,0 +1,5 @@
fetch('http://rosettacode.org').then(function(response) {
return response.text();
}).then(function(myText) {
console.log(myText);
});

View file

@ -0,0 +1,65 @@
/**
* @name _http
* @description Generic API Client using XMLHttpRequest
* @param {string} url The URI/URL to connect to
* @param {string} method The HTTP method to invoke- GET, POST, etc
* @param {function} callback Once the HTTP request has completed, responseText is passed into this function for execution
* @param {object} params Query Parameters in a JavaScript Object (Optional)
*
*/
function _http(url, method, callback, params) {
var xhr,
reqUrl;
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function xhrProc() {
if (xhr.readyState == 4 && xhr.status == 200) {
callback(xhr.responseText);
}
};
/** If Query Parameters are present, handle them... */
if (typeof params === 'undefined') {
reqUrl = url;
} else {
switch (method) {
case 'GET':
reqUrl = url + procQueryParams(params);
break;
case 'POST':
reqUrl = url;
break;
default:
}
}
/** Send the HTTP Request */
if (reqUrl) {
xhr.open(method, reqUrl, true);
xhr.setRequestHeader("Accept", "application/json");
if (method === 'POST') {
xhr.send(params);
} else {
xhr.send();
}
}
/**
* @name procQueryParams
* @description Return function that converts Query Parameters from a JavaScript Object to a proper URL encoded string
* @param {object} params Query Parameters in a JavaScript Object
*
*/
function procQueryParams(params) {
return "?" + Object
.keys(params)
.map(function (key) {
return key + "=" + encodeURIComponent(params[key])
})
.join("&")
}
}

View file

@ -0,0 +1,3 @@
$.get('http://rosettacode.org', function(data) {
console.log(data);
};

View file

@ -0,0 +1,19 @@
const http = require('http');
http.get('http://rosettacode.org', (resp) => {
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
resp.on('end', () => {
console.log("Data:", data);
});
}).on("error", (err) => {
console.log("Error: " + err.message);
});

108
Task/HTTP/Jsish/http.jsish Normal file
View file

@ -0,0 +1,108 @@
#!/usr/bin/env jsish
function httpGet(fileargs:array|string, conf:object=void) {
var options = { // Web client for downloading files from url
headers : [], // Header fields to send.
nowait : false, // Just return object: caller will call update.
onDone : null, // Callback when done.
wsdebug : 0 // WebSockets debug level.
};
var self = {
address : '',
done : false,
path : '',
port : -1,
post : '', // Post file upload (UNIMPL).
scheme : 'http', // Url scheme
protocol : 'get',
url : null,
response : ''
};
parseOpts(self, options, conf);
if (self.port === -1)
self.port = 80;
function WsRecv(ws:userobj, id:number, str:string) {
LogDebug("LEN: "+str.length);
LogTrace("DATA", str);
self.response += str;
}
function WsClose(ws:userobj|null, id:number) {
LogDebug("CLOSE");
self.done = true;
if (self.onDone)
self.onDone(id);
}
function main() {
if (self.Debug)
debugger;
if (typeof(fileargs) === 'string')
fileargs = [fileargs];
if (!fileargs || fileargs.length !== 1)
throw("expected a url arg");
self.url = fileargs[0];
var m = self.url.match(/^([a-zA-Z]+):\/\/([^\/]*+)(.*)$/);
if (!m)
throw('invalid url: '+self.url);
self.scheme = m[1];
self.address = m[2];
self.path = m[3];
var as = self.address.split(':');
if (as.length==2) {
self.port = parseInt(as[1]);
self.address = as[0];
} else if (as.length != 1)
throw('bad port in address: '+self.address);
if (self.path=='')
self.path = '/index.html';
if (self.post.length)
self.protocol = 'post';
var wsopts = {
client:true,
onRecv:WsRecv,
onClose:WsClose,
debug:self.wsdebug,
rootdir:self.path,
port:self.port,
address:self.address,
protocol:self.protocol,
clientHost:self.address
};
if (self.post.length)
wsopts.post = self.post;
if (self.headers.length)
wsopts.headers = self.headers;
if (self.scheme === 'https') {
if (!Interp.conf('hasOpenSSL'))
puts('SSL is not compiled in: falling back to http:');
else {
if (self.port === 80)
wsopts.port = 441;
wsopts.use_ssl = true;
}
}
LogDebug("Starting:", conf, wsopts);
self.ws = new WebSocket( wsopts );
if (self.nowait)
return self;
while (!self.done) {
update(200);
LogTrace("UPDATE");
}
delete self.ws;
return self.response;
}
return main();
}
provide(httpGet, "0.60");
if (isMain())
runModule(httpGet);

View file

@ -0,0 +1,3 @@
readurl(url) = open(readlines, download(url))
readurl("http://rosettacode.org/index.html")

View file

@ -0,0 +1,13 @@
// version 1.1.2
import java.net.URL
import java.io.InputStreamReader
import java.util.Scanner
fun main(args: Array<String>) {
val url = URL("http://www.puzzlers.org/pub/wordlists/unixdict.txt")
val isr = InputStreamReader(url.openStream())
val sc = Scanner(isr)
while (sc.hasNextLine()) println(sc.nextLine())
sc.close()
}

6
Task/HTTP/LFE/http-1.lfe Normal file
View file

@ -0,0 +1,6 @@
(: inets start)
(case (: httpc request '"http://lfe.github.io")
((tuple 'ok result)
(: io format '"Result: ~p" (list result)))
((tuple 'error reason)
(: io format '"Error: ~p~n" (list reason))))

13
Task/HTTP/LFE/http-2.lfe Normal file
View file

@ -0,0 +1,13 @@
(: inets start)
(let* ((method 'get)
(url '"http://lfe.github.io")
(headers ())
(request-data (tuple url headers))
(http-options ())
(request-options (list (tuple 'sync 'false))))
(: httpc request method request-data http-options request-options)
(receive
((tuple 'http (tuple request-id (tuple 'error reason)))
(: io format '"Error: ~p~n" (list reason)))
((tuple 'http (tuple request-id result))
(: io format '"Result: ~p~n" (list result))))))

20
Task/HTTP/LSL/http.lsl Normal file
View file

@ -0,0 +1,20 @@
string sURL = "http://www.RosettaCode.Org";
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));
}
}
}
}

View file

@ -0,0 +1,10 @@
// using include_url wrapper:
include_url('http://rosettacode.org/index.html')
// one line curl
curl('http://rosettacode.org/index')->result->asString
// using curl for more complex operations and feedback
local(x = curl('http://rosettacode.org/index'))
local(y = #x->result)
#y->asString

View file

@ -0,0 +1,20 @@
result = DownloadToFile( "http://rosettacode.org/wiki/Main_Page", "in.html")
timer 2000, [on]
wait
[on]
timer 0
if result <> 0 then print "Error downloading."
end
Function DownloadToFile( urlfile$, localfile$)
open "URLmon" for dll as #url
calldll #url, "URLDownloadToFileA",_
0 as long,_ 'null
urlfile$ as ptr,_ 'url to download
localfile$ as ptr,_ 'save file name
0 as long,_ 'reserved, must be 0
0 as long,_ 'callback address, can be 0
DownloadToFile as ulong '0=success
close #url
end function

View file

@ -0,0 +1,30 @@
property _netID
property _cbHandler
property _cbTarget
----------------------------------------
-- Simple HTTP GET request
-- @param {string} url
-- @param {symbol} cbHandler
-- @param {object} [cbTarget=_movie]
----------------------------------------
on new (me, url, cbHandler, cbTarget)
if voidP(cbTarget) then cbTarget = _movie
me._netID = getNetText(url)
me._cbHandler = cbHandler
me._cbTarget = cbTarget
_movie.actorList.add(me)
return me
end
----------------------------------------
-- @callback
----------------------------------------
on stepFrame (me)
if netDone(me._netID) then
res = netTextResult(me._netID)
err = netError(me._netID)
_movie.actorList.deleteOne(me)
call(me._cbHandler, me._cbTarget, res, err)
end if
end

View file

@ -0,0 +1,17 @@
----------------------------------------
--
----------------------------------------
on getAdobeHomePage ()
script("SimpleHttpGet").new("http://www.adobe.com/", #printResult)
end
----------------------------------------
-- @callback
----------------------------------------
on printResult (res, err)
if err="OK" then
put res
else
put "Network Error:" && err
end if
end

View file

@ -0,0 +1,3 @@
getAdobeHomePage()
-- "<!doctype html>
...

View file

@ -0,0 +1,3 @@
put true into libURLFollowHttpRedirects
get URL "http://httpbin.org/html"
put it

View file

@ -0,0 +1,7 @@
on myUrlDownloadFinished
answer "Download Complete" with "Okay"
end myUrlDownloadFinished
command getWebResource
load URL "http://httpbin.org/html" with message "myUrlDownloadFinished"
end getWebResource

4
Task/HTTP/Lua/http.lua Normal file
View file

@ -0,0 +1,4 @@
local http = require("socket.http")
local url = require("socket.url")
local page = http.request('http://www.google.com/m/search?q=' .. url.escape("lua"))
print(page)

View file

@ -0,0 +1,29 @@
Module CheckIt {
Declare xml "Microsoft.XMLHTTP"
const testUrl$ = "http://www.rosettacode.org"
With xml, "readyState" as ReadyState
Method xml "Open", "Get", testUrl$, True ' True means Async
Method xml "send"
\\ We set a thread to count time
k=0
Thread {
k++
} as TimeOut interval 100
\\ In main thread we can check ReadyState and Mouse button
Task.Main 100 {
Print ReadyState
If ReadyState=4 then exit
if k>20 then exit ' 20*100= 2 sec
if mouse then exit ' exit if mouse click
}
\\ So now we can read
if ReadyState=4 then {
With xml, "responseText" AS AA$
\\ break AA$ to lines
Document BB$=AA$
\\ using line breaks as CRLF
Report BB$
}
Declare xml Nothing
}
CheckIt

5
Task/HTTP/MATLAB/http.m Normal file
View file

@ -0,0 +1,5 @@
>> random = urlread('http://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new')
random =
61

View file

@ -0,0 +1 @@
content := URL:-Get( "http://www.google.com/" );

View file

@ -0,0 +1 @@
content := HTTP:-Get( "http://www.google.com/" );

View file

@ -0,0 +1 @@
Print[Import["http://www.google.com/webhp?complete=1&hl=en", "Source"]]

View file

@ -0,0 +1 @@
TextWindow.WriteLine(Network.GetWebPageContents("http://rosettacode.org"))

View file

@ -0,0 +1,9 @@
import http
import url
url = new(URL, "http://rosettacode.org/wiki/Rosetta_Code")
client = new(HTTPClient, url.getHost())
client.connect()
response = client.get(url.getFile())
println response.get("body")

View file

@ -0,0 +1,17 @@
using System;
using System.Console;
using System.Net;
using System.IO;
module HTTP
{
Main() : void
{
def wc = WebClient();
def myStream = wc.OpenRead("http://rosettacode.org");
def sr = StreamReader(myStream);
WriteLine(sr.ReadToEnd());
myStream.Close()
}
}

View file

@ -0,0 +1,17 @@
/* NetRexx */
options replace format comments java crossref symbols binary
import java.util.Scanner
import java.net.URL
do
rosettaUrl = "http://www.rosettacode.org"
sc = Scanner(URL(rosettaUrl).openStream)
loop while sc.hasNext
say sc.nextLine
end
catch ex = Exception
ex.printStackTrace
end
return

1
Task/HTTP/NewLISP/http.l Normal file
View file

@ -0,0 +1 @@
(get-url "http://www.rosettacode.org")

4
Task/HTTP/Nim/http.nim Normal file
View file

@ -0,0 +1,4 @@
import httpclient
var client = newHttpClient()
echo client.getContent "http://rosettacode.org"

View file

@ -0,0 +1,5 @@
let () =
let url = "http://www.rosettacode.org" in
let _,_, page_content = make_request ~url ~kind:GET () in
print_endline page_content;
;;

Some files were not shown because too many files have changed in this diff Show more