isahc icon indicating copy to clipboard operation
isahc copied to clipboard

config add use_default_http_client option

Open izhengzhixian opened this issue 2 years ago • 0 comments

I use curl-impersonate to load as a dynamic link library to simulate browser downloads. When the header is not set, the header of the browser will be automatically filled, but isahc has set the user-agent, so it will not be overwritten by the user-agent of chrome. So I hope there can be a config field to turn off the default user-agent during use.

        let use_default_user_agent = request
            .extensions()
            .get::<RequestConfig>()
            .unwrap()
            .use_default_user_agent
            .unwrap_or(true);

        if use_default_user_agent {
            // Set default user agent if not specified.
            request
                .headers_mut()
                .entry(http::header::USER_AGENT)
                .or_insert(USER_AGENT.parse().unwrap());
        }

izhengzhixian avatar Jul 14 '23 16:07 izhengzhixian