Script Library: 1240 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 
View scriptLicenseDownload documentation as: HTML or editable
Download scriptHistoryOther scripts by: sergey

Documentation for: reads.r


This function allows you to receive files from the network/Internet 
using modern versions of the SSL/TSL protocols.

The standard functions return an error:
>> read https://microsoft.com

** Command Error: SSL Error:  error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 
alert protocol version
** Where: build-port
** Near: system/words/set-modes port/sub-port [secure: true]

This function allows you to get the contents of a file without errors:
>> reads https://microsoft.com
== {
<!DOCTYPE html><html xmlns:mscom="http://schemas.microsoft.com/CMSvNext"
        xmlns:md="http://schemas.microsoft.com/mscom-...


The work is carried out by means of a PHP script, which can be accessed 
via the HTTP or HTTPS/TLS-1 protocol. Having received the address, 
the script downloads the file using CURL and modern versions of encryption 
protocols. After downloading, it returns its contents.

PHP script code:
<?php
$options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page

        CURLOPT_HEADER         => false,    // do not return headers

        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_USERAGENT      => "Rebol",    // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect

        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect

        CURLOPT_TIMEOUT        => 120,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects 
    ); 
    $ch      = curl_init( $_GET['q'] ); 
    curl_setopt_array( $ch, $options ); 
    $content = curl_exec( $ch ); 
    $err     = curl_errno( $ch ); 
    $errmsg  = curl_error( $ch ); 
    $header  = curl_getinfo( $ch ); 
    curl_close( $ch ); 
    echo $content;     
?>