Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A AndroidAsync
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 333
    • Issues 333
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 19
    • Merge requests 19
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Koushik Dutta
  • AndroidAsync
  • Issues
  • #714
Closed
Open
Issue created Dec 08, 2022 by zll123dxd@zll123dxd

Can not add Http Header

I'm not sure if this project is still maintained, try asking.

I have configured a proxy with authentication in my android project. There are two options to achieve

  1. extends SimpleMiddleware, and add Proxy-Authorization in the onRequest function.
  2. Call addHeader [Proxy-Authorization] in AsyncHttpRequest. Check the http message through tcpdump, it tries to connect to the target proxy, but it does not carry the [Proxy-Authorization] I added.

I don't know if I used it wrong, attach a piece of code:

    Headers header = new Headers();
    String baseAuth = Base64.encodeToString(("test:12345678").getBytes(), Base64.NO_WRAP);
    AsyncHttpRequest.setDefaultHeaders(header, Uri.parse(url));
    header.set("Proxy-Authorization", "Basic " + baseAuth);
    AsyncHttpGet request = new AsyncHttpGet(url);
    request.setHeader("Proxy-Authorization", "Basic " + baseAuth);
    view.setText(request.toString());
    mClient.executeString(request, mCallback);

If I configure this parameter in the okhttp framework, I can successfully connect. So I think there is nothing wrong with the parameters of the header.

I checked the code of the AsyncHttp framework, I think the default does not support Proxy-Auth, so I want to manually add the http header, but it is invalid, if anyone has a suitable solution, please help me.

Assignee
Assign to
Time tracking