swift-server / swift-server/async-http-client

Doesn't work with usefixie and quotaguard with `invalidProxyResponse `

Open
#650 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
1.1k
Forks
156
PR merge metrics
No merged PRs in 30d

Description

I tried to use it with usefixie.com and quotaguard.com and getting invalidProxyResponse error.

I tried to set breakpoints to debug the issue and see that under the hood these services returns 400 Bad Request

let auth = HTTPClient.Authorization.basic(username: "fixie", password: "___")
let proxyConfig = HTTPClient.Configuration.Proxy.server(host: "___.usefixie.com", port: 80, authorization: auth)
app.http.client.configuration.proxy = proxyConfig
//app.http.client.configuration.redirectConfiguration = .follow(max: 100, allowCycles: true)
do {
    let res = try app.client.get(URI("https://ip.quotaguard.com/")).wait()
    app.logger.critical("\(res.body?.string)")
} catch {
    app.logger.critical("Error: \(error)") // getting HTTPClientError.invalidProxyResponse here
}

at the same time with nodejs everything works fine

var http = require('http');

function buildAuthHeader(user, pass) {
    return 'Basic ' + new Buffer(user + ':' + pass).toString('base64');
}

proxy = '___.usefixie.com';
proxy_port = 80;
host = 'ip.quotaguard.com';
url = 'https://ip.quotaguard.com';
user = 'fixie';
pass = '___';

var options = {
    port: proxy_port,
    host: proxy,
    path: url,
    headers: {
        Host: host,
        'Proxy-Authorization': buildAuthHeader(user, pass),
    }
};

http.get(options, function(res) {
  console.log("StatusCode: " + res.statusCode + " Message: " + res.statusMessage);
  let chunks = []
    res.on('data', chunk => chunks.push(chunk))
    res.on('end', () => {
      console.log('DONE', Buffer.concat(chunks).toString('utf8'))
    })
}).end();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with HTTPClient.Configuration.Proxy.server and the reported invalidProxyResponse path, using the Swift reproduction against usefixie.com or quotaguard.com. Compare its proxy request behavior with the working Node.js example; done means the HTTPS request succeeds through the authenticated proxy without invalidProxyResponse.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, swift
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.