Skip to content

Commit ed2643a

Browse files
committed
Remove urlencoding feature
There is no longer a dependency on the urlencoding crate. Remove the feature and all related feature gates and comments.
1 parent 29a0d45 commit ed2643a

File tree

4 files changed

+4
-28
lines changed

4 files changed

+4
-28
lines changed

bitreq/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ json-using-serde = ["serde", "serde_json"]
5151
proxy = ["base64", "std"]
5252
async = ["tokio", "std"]
5353
async-https = ["async", "https-rustls", "tokio-rustls"]
54-
urlencoding = []
5554

5655
[[example]]
5756
name = "hello"

bitreq/src/http_url.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ impl HttpUrl {
9696
path_and_query = Some(resource);
9797
resource = String::new();
9898
}
99-
#[cfg(not(feature = "urlencoding"))]
100-
UrlParseStatus::PathAndQuery | UrlParseStatus::Fragment => resource.push(c),
101-
#[cfg(feature = "urlencoding")]
10299
UrlParseStatus::PathAndQuery | UrlParseStatus::Fragment => match c {
103100
// All URL-'safe' characters, plus URL 'special
104101
// characters' like &, #, =, / ,?
@@ -175,15 +172,13 @@ impl HttpUrl {
175172
}
176173

177174
/// Returns the `%HH` triplet representing `byte` for percent encoding.
178-
#[cfg(feature = "urlencoding")]
179175
fn percent_encoded_triplet(byte: u8) -> [char; 3] {
180176
const HEX: &[u8; 16] = b"0123456789ABCDEF";
181177
['%', HEX[(byte >> 4) as usize] as char, HEX[(byte & 0x0F) as usize] as char]
182178
}
183179

184180
/// Percent-encodes a char and appends it to `result`.
185181
/// Unreserved characters (0-9, A-Z, a-z, -, ., _, ~) are not encoded.
186-
#[cfg(feature = "urlencoding")]
187182
pub(crate) fn percent_encode_char(c: char, result: &mut String) {
188183
match c {
189184
// All URL-'safe' characters are not encoded
@@ -203,7 +198,6 @@ pub(crate) fn percent_encode_char(c: char, result: &mut String) {
203198
}
204199

205200
/// Percent-encodes the entire input string and returns the encoded version.
206-
#[cfg(feature = "urlencoding")]
207201
pub(crate) fn percent_encode_string(input: &str) -> String {
208202
let mut encoded = String::with_capacity(input.len());
209203
for ch in input.chars() {

bitreq/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@
7272
//!
7373
//! This feature enables HTTP proxy support. See [Proxy].
7474
//!
75-
//! ## `urlencoding`
76-
//!
77-
//! This feature enables percent-encoding for the URL resource when
78-
//! creating a request and any subsequently added parameters from
79-
//! [`Request::with_param`].
80-
//!
8175
//! # Examples
8276
//!
8377
//! ## Get

bitreq/src/request.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use core::fmt::Write;
77
use crate::connection::AsyncConnection;
88
#[cfg(feature = "std")]
99
use crate::connection::Connection;
10-
#[cfg(feature = "urlencoding")]
1110
use crate::http_url::percent_encode_string;
1211
#[cfg(feature = "std")]
1312
use crate::http_url::{HttpUrl, Port};
@@ -100,12 +99,8 @@ impl Request {
10099
/// This is only the request's data, it is not sent yet. For
101100
/// sending the request, see [`send`](struct.Request.html#method.send).
102101
///
103-
/// If `urlencoding` is not enabled, it is the responsibility of the
104-
/// user to ensure there are no illegal characters in the URL.
105-
///
106-
/// If `urlencoding` is enabled, the resource part of the URL will be
107-
/// encoded. Any URL special characters (e.g. &, #, =) are not encoded
108-
/// as they are assumed to be meaningful parameters etc.
102+
/// The resource part of the URL will be encoded. Any URL special characters (e.g. &, #, =) are
103+
/// not encoded as they are assumed to be meaningful parameters etc.
109104
pub fn new<T: Into<URL>>(method: Method, url: T) -> Request {
110105
Request {
111106
method,
@@ -153,17 +148,11 @@ impl Request {
153148
/// Adds given key and value as query parameter to request url
154149
/// (resource).
155150
///
156-
/// If `urlencoding` is not enabled, it is the responsibility
157-
/// of the user to ensure there are no illegal characters in the
158-
/// key or value.
159-
///
160-
/// If `urlencoding` is enabled, the key and value are both encoded.
151+
/// The key and value are both encoded.
161152
pub fn with_param<T: Into<String>, U: Into<String>>(mut self, key: T, value: U) -> Request {
162153
let key = key.into();
163-
#[cfg(feature = "urlencoding")]
164154
let key = percent_encode_string(&key);
165155
let value = value.into();
166-
#[cfg(feature = "urlencoding")]
167156
let value = percent_encode_string(&value);
168157

169158
if !self.params.is_empty() {
@@ -612,7 +601,7 @@ mod parsing_tests {
612601
}
613602
}
614603

615-
#[cfg(all(test, feature = "urlencoding"))]
604+
#[cfg(test)]
616605
mod encoding_tests {
617606
use super::{get, ParsedRequest};
618607

0 commit comments

Comments
 (0)