Adding proxy support to Cronet

Skip to first unread message

Lucas Moauro

Feb 27, 2024, 11:10:57 AMFeb 27

I'm working on an open source library that will provide python bindings for libcronet and an important feature is to support proxies so that I can provide similar features to requests or httpx.

I see that there's an open issue for that at the moment:

I would like to work on that issue and I'm wondering if there are any high level suggestions on how to approach the problem from an experienced chromium dev. Also I'm interested in implementing it to be configurable per request and not just a single proxy for the Cronet engine.


Sebastian Poreba

Feb 27, 2024, 12:16:53 PMFeb 27
to Lucas Moauro,
libcronet does not have a stable interface, and we suggest you do not create additional bindings to it, as no guarantees exist that we would not break you in the future. We only support libcronet on Android, and only via CronetEngine.

We also don't have an ETA for proxy support, or per-request configuration in CronetEngine - we are currently considering both of these features.


  •  Sebastian Poręba
  •  Engineering Manager

You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Lucas Moauro

Feb 27, 2024, 2:01:59 PMFeb 27
to Sebastian Poreba,
The bindings won't be too tied to the API internals so I can update them if cronet changes. I think it's a very useful library to use outside of Android and it's more lightweight than running headless chrome if you just need to run chrome's network stack.

I have been testing how to set the proxy and it looks like it's not too difficult to do it per cronet engine. Per request it seems difficult.

I added a class like the following one:

class ProxyConfigServiceSingle : public net::ProxyConfigService {
  // ProxyConfigServiceSingle implementation:
  void AddObserver(Observer* observer) override {}
  void RemoveObserver(Observer* observer) override {}
  ConfigAvailability GetLatestProxyConfig(
      net::ProxyConfigWithAnnotation* config) override {
    auto proxy_config = net::ProxyConfig();
    auto annotation = net::DefineNetworkTrafficAnnotation("test", "test");
    *config = net::ProxyConfigWithAnnotation(proxy_config, annotation);
    return CONFIG_VALID;

and then modified CreateProxyConfigService to use it.

Reply all
Reply to author
0 new messages