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
- extends SimpleMiddleware, and add Proxy-Authorization in the onRequest function.
- 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.