Using HTTPS for connection to Super Proxy

Node.js

let auth = 'USER:PASS';
let https = require('https');
let agent = new https.Agent({keepAlive: true, keepAliveMsecs: 5000,
    servername: 'zproxy.lum-superproxy.io'})
let conn = https.request({
    host: 'zproxy.lum-superproxy.io',
    port: 22225,
    method: 'CONNECT',
    path: 'lumtest.com:443',
    agent,
    headers: {
        'Proxy-Authorization': 'Basic '+Buffer.from(auth).toString('base64'),
    }
})
.on('connect', (res, socket, head)=>{
    if (res.statusCode!=200)
        console.error('CONNECT failed:\n'+res.headers);
    res.on('error', e=>console.error('CONNECT error: '+e.message));
    socket.on('error', e=>console.error('socket error: '+e.message));
    socket.on('timeout', e=>console.error('socket timeout: '+e.message));
    https.get('https://lumtest.com/myip.json', {
        socket,
        agent: false,
    }, res=>{
        res.on('data', d=>console.log(Buffer.from(d).toString()));
    });
})
.on('error', console.error)
.end();

Python

import http.client
import base64
creds = 'USER:PASS'
auth = 'Basic ' + base64.encodebytes(creds.encode()).decode()
try:
    conn = http.client.HTTPSConnection("zproxy.lum-superproxy.io", 22225)
    conn.set_tunnel("lumtest.com", 443, {"Proxy-Authorization": auth})
    conn.connect()
    conn.request("GET","/myip.json")
    response = conn.getresponse()
    data = response.read()
    print(data)
except OSError as msg:
    print(msg)
conn.close()

Was this article helpful?