Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions bitreq/.github/workflows/lint.yml

This file was deleted.

24 changes: 0 additions & 24 deletions bitreq/.github/workflows/msrv.yml

This file was deleted.

63 changes: 0 additions & 63 deletions bitreq/.github/workflows/unit-tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion bitreq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ https = ["https-rustls"]
https-rustls = ["rustls", "webpki-roots", "rustls-webpki"]
https-rustls-probe = ["rustls", "rustls-native-certs"]
json-using-serde = ["serde", "serde_json"]
proxy = ["base64"]
proxy = ["base64", "std"]
async = ["tokio", "std"]
async-https = ["async", "https-rustls", "tokio-rustls"]

Expand Down
2 changes: 0 additions & 2 deletions bitreq/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# bitreq - forked from minreq
[![Crates.io](https://img.shields.io/crates/d/bitreq.svg)](https://crates.io/crates/bitreq)
[![Documentation](https://docs.rs/bitreq/badge.svg)](https://docs.rs/bitreq)
![Unit tests](https://github.com/tcharding/bitreq/actions/workflows/unit-tests.yml/badge.svg)
![MSRV](https://github.com/tcharding/bitreq/actions/workflows/msrv.yml/badge.svg)

This crate is a fork for the very nice
[minreq](https://github.com/neonmoe/minreq). I chose to fork and
Expand Down
14 changes: 14 additions & 0 deletions bitreq/contrib/test_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# No shebang, this file should not be executed.
# shellcheck disable=SC2148
#
# disable verify unused vars, despite the fact that they are used when sourced
# shellcheck disable=SC2034

# Test all these features with "std" enabled.
FEATURES_WITH_STD="log https https-rustls proxy async async-https"

# Test all these features without "std" enabled.
FEATURES_WITHOUT_STD="log https https-rustls"

# Run these examples.
EXAMPLES=""
6 changes: 2 additions & 4 deletions bitreq/examples/no-std.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! This is a simple example to demonstrate the usage of this library.

#![cfg(feature = "std")]

const _RESPONSE: &str = r#"<!doctype html>
<html>
<head>
Expand All @@ -16,7 +14,7 @@ const _RESPONSE: &str = r#"<!doctype html>
margin: 0;
padding: 0;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

}
div {
width: 600px;
Expand All @@ -36,7 +34,7 @@ const _RESPONSE: &str = r#"<!doctype html>
width: auto;
}
}
</style>
</style>
</head>

<body>
Expand Down
12 changes: 7 additions & 5 deletions bitreq/src/connection/rustls_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use alloc::sync::Arc;
use core::convert::TryFrom;
use std::io::{self, Write};
use std::net::TcpStream;
use std::sync::OnceLock;

use rustls::{self, ClientConfig, ClientConnection, RootCertStore, ServerName, StreamOwned};
#[cfg(feature = "rustls-webpki")]
Expand All @@ -15,8 +16,9 @@ use crate::Error;

pub type SecuredStream = StreamOwned<ClientConnection, TcpStream>;

#[allow(clippy::incompatible_msrv)] // We only guarantee MSRV for a subset of features.
static CONFIG: std::sync::LazyLock<Arc<ClientConfig>> = std::sync::LazyLock::new(|| {
static CONFIG: OnceLock<Arc<ClientConfig>> = OnceLock::new();

fn build_client_config() -> Arc<ClientConfig> {
let mut root_certificates = RootCertStore::empty();

// Try to load native certs
Expand Down Expand Up @@ -44,7 +46,7 @@ static CONFIG: std::sync::LazyLock<Arc<ClientConfig>> = std::sync::LazyLock::new
.with_root_certificates(root_certificates)
.with_no_client_auth();
Arc::new(config)
});
}

pub fn create_secured_stream(conn: &Connection) -> Result<HttpStream, Error> {
// Rustls setup
Expand All @@ -54,8 +56,8 @@ pub fn create_secured_stream(conn: &Connection) -> Result<HttpStream, Error> {
Ok(result) => result,
Err(err) => return Err(Error::IoError(io::Error::new(io::ErrorKind::Other, err))),
};
let sess =
ClientConnection::new(CONFIG.clone(), dns_name).map_err(Error::RustlsCreateConnection)?;
let sess = ClientConnection::new(CONFIG.get_or_init(build_client_config).clone(), dns_name)
.map_err(Error::RustlsCreateConnection)?;

// Connect
#[cfg(feature = "log")]
Expand Down
2 changes: 1 addition & 1 deletion contrib/crates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# shellcheck disable=SC2148

# Crates in this workspace to test.
CRATES=("types" "client" "jsonrpc")
CRATES=("bitreq" "client" "jsonrpc" "types")