<commit_before>use super::common::sha256_hex;
use super::ct::AddChainRequest;
use base64;
use hyper;
use serde_json;
use url;

pub fn build_chain_for_cert(http_client: &hyper::Client, cert: &[u8]) -> Option<Vec<Vec<u8>>> {
    let body = url::form_urlencoded::Serializer::new(String::new())
        .append_pair("b64cert", &base64::encode(cert))
        .finish();
    let body_bytes = body.as_bytes();
    let response = http_client
        .post("https://crt.sh/gen-add-chain")
        .header(hyper::header::ContentType::form_url_encoded())
        .body(hyper::client::Body::BufBody(body_bytes, body_bytes.len()))
        .send()
        .unwrap();

    if response.status == hyper::status::StatusCode::NotFound {
        return None;<commit_msg>Don't blow up on connection issues with crt.sh<commit_after>use super::common::sha256_hex;
use super::ct::AddChainRequest;
use base64;
use hyper;
use serde_json;
use url;

pub fn build_chain_for_cert(http_client: &hyper::Client, cert: &[u8]) -> Option<Vec<Vec<u8>>> {
    let body = url::form_urlencoded::Serializer::new(String::new())
        .append_pair("b64cert", &base64::encode(cert))
        .finish();
    let body_bytes = body.as_bytes();
    let response = match http_client
        .post("https://crt.sh/gen-add-chain")
        .header(hyper::header::ContentType::form_url_encoded())
        .body(hyper::client::Body::BufBody(body_bytes, body_bytes.len()))
        .send() {
        Ok(response) => response,
        // TODO: maybe be more selective in error handling
        Err(_) => return None,
    };

    if response.status == hyper::status::StatusCode::NotFound {
        return None;
{'fraction_non_alphanumeric': 0.16212946158499697, 'fraction_numerical': 0.013309134906231096, 'mean_word_length': 3.8362573099415203, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7004936', 'n_tokens_mistral': 540, 'n_tokens_neox': 527, 'n_words': 103}