Skip to content

Commit 80e4ee8

Browse files
committed
feat: v17.0.0
1 parent 64914b1 commit 80e4ee8

3 files changed

Lines changed: 20 additions & 200 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "http-type"
3-
version = "16.2.1"
3+
version = "17.0.0"
44
readme = "README.md"
55
edition = "2024"
66
authors = ["root@ltpp.vip"]

src/request/impl.rs

Lines changed: 1 addition & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,186 +1211,6 @@ impl Request {
12111211
self.try_get_body_json().unwrap()
12121212
}
12131213

1214-
/// Checks whether the request method is GET.
1215-
///
1216-
/// # Returns
1217-
///
1218-
/// - `bool` - Whether the method is GET.
1219-
#[inline(always)]
1220-
pub fn is_get_method(&self) -> bool {
1221-
self.get_method().is_get()
1222-
}
1223-
1224-
/// Checks whether the request method is POST.
1225-
///
1226-
/// # Returns
1227-
///
1228-
/// - `bool` - Whether the method is POST.
1229-
#[inline(always)]
1230-
pub fn is_post_method(&self) -> bool {
1231-
self.get_method().is_post()
1232-
}
1233-
1234-
/// Checks whether the request method is PUT.
1235-
///
1236-
/// # Returns
1237-
///
1238-
/// - `bool` - Whether the method is PUT.
1239-
#[inline(always)]
1240-
pub fn is_put_method(&self) -> bool {
1241-
self.get_method().is_put()
1242-
}
1243-
1244-
/// Checks whether the request method is DELETE.
1245-
///
1246-
/// # Returns
1247-
///
1248-
/// - `bool` - Whether the method is DELETE.
1249-
#[inline(always)]
1250-
pub fn is_delete_method(&self) -> bool {
1251-
self.get_method().is_delete()
1252-
}
1253-
1254-
/// Checks whether the request method is PATCH.
1255-
///
1256-
/// # Returns
1257-
///
1258-
/// - `bool` - Whether the method is PATCH.
1259-
#[inline(always)]
1260-
pub fn is_patch_method(&self) -> bool {
1261-
self.get_method().is_patch()
1262-
}
1263-
1264-
/// Checks whether the request method is HEAD.
1265-
///
1266-
/// # Returns
1267-
///
1268-
/// - `bool` - Whether the method is HEAD.
1269-
#[inline(always)]
1270-
pub fn is_head_method(&self) -> bool {
1271-
self.get_method().is_head()
1272-
}
1273-
1274-
/// Checks whether the request method is OPTIONS.
1275-
///
1276-
/// # Returns
1277-
///
1278-
/// - `bool` - Whether the method is OPTIONS.
1279-
#[inline(always)]
1280-
pub fn is_options_method(&self) -> bool {
1281-
self.get_method().is_options()
1282-
}
1283-
1284-
/// Checks whether the request method is CONNECT.
1285-
///
1286-
/// # Returns
1287-
///
1288-
/// - `bool` - Whether the method is CONNECT.
1289-
#[inline(always)]
1290-
pub fn is_connect_method(&self) -> bool {
1291-
self.get_method().is_connect()
1292-
}
1293-
1294-
/// Checks whether the request method is TRACE.
1295-
///
1296-
/// # Returns
1297-
///
1298-
/// - `bool` - Whether the method is TRACE.
1299-
#[inline(always)]
1300-
pub fn is_trace_method(&self) -> bool {
1301-
self.get_method().is_trace()
1302-
}
1303-
1304-
/// Checks whether the request method is UNKNOWN.
1305-
///
1306-
/// # Returns
1307-
///
1308-
/// - `bool` - Whether the method is UNKNOWN.
1309-
#[inline(always)]
1310-
pub fn is_unknown_method(&self) -> bool {
1311-
self.get_method().is_unknown()
1312-
}
1313-
1314-
/// Checks whether the HTTP version is HTTP/0.9.
1315-
///
1316-
/// # Returns
1317-
///
1318-
/// - `bool` - Whether the version is HTTP/0.9.
1319-
#[inline(always)]
1320-
pub fn is_http0_9_version(&self) -> bool {
1321-
self.get_version().is_http0_9()
1322-
}
1323-
1324-
/// Checks whether the HTTP version is HTTP/1.0.
1325-
///
1326-
/// # Returns
1327-
///
1328-
/// - `bool` - Whether the version is HTTP/1.0.
1329-
#[inline(always)]
1330-
pub fn is_http1_0_version(&self) -> bool {
1331-
self.get_version().is_http1_0()
1332-
}
1333-
1334-
/// Checks whether the HTTP version is HTTP/1.1.
1335-
///
1336-
/// # Returns
1337-
///
1338-
/// - `bool` - Whether the version is HTTP/1.1.
1339-
#[inline(always)]
1340-
pub fn is_http1_1_version(&self) -> bool {
1341-
self.get_version().is_http1_1()
1342-
}
1343-
1344-
/// Checks whether the HTTP version is HTTP/2.
1345-
///
1346-
/// # Returns
1347-
///
1348-
/// - `bool` - Whether the version is HTTP/2.
1349-
#[inline(always)]
1350-
pub fn is_http2_version(&self) -> bool {
1351-
self.get_version().is_http2()
1352-
}
1353-
1354-
/// Checks whether the HTTP version is HTTP/3.
1355-
///
1356-
/// # Returns
1357-
///
1358-
/// - `bool` - Whether the version is HTTP/3.
1359-
#[inline(always)]
1360-
pub fn is_http3_version(&self) -> bool {
1361-
self.get_version().is_http3()
1362-
}
1363-
1364-
/// Checks if the HTTP version is HTTP/1.1 or higher.
1365-
///
1366-
/// # Returns
1367-
///
1368-
/// - `bool` - Whether the version is HTTP/1.1 or higher.
1369-
#[inline(always)]
1370-
pub fn is_http1_1_or_higher_version(&self) -> bool {
1371-
self.get_version().is_http1_1_or_higher()
1372-
}
1373-
1374-
/// Checks whether the version belongs to the HTTP family.
1375-
///
1376-
/// # Returns
1377-
///
1378-
/// - `bool` - Whether the version is HTTP.
1379-
#[inline(always)]
1380-
pub fn is_http_version(&self) -> bool {
1381-
self.get_version().is_http()
1382-
}
1383-
1384-
/// Checks whether the HTTP version is unknown.
1385-
///
1386-
/// # Returns
1387-
///
1388-
/// - `bool` - Whether the version is unknown.
1389-
#[inline(always)]
1390-
pub fn is_unknown_version(&self) -> bool {
1391-
self.get_version().is_unknown()
1392-
}
1393-
13941214
/// Checks whether the WebSocket upgrade is enabled for this request.
13951215
///
13961216
/// This method determines if the `UPGRADE` header indicates a WebSocket connection.
@@ -1457,7 +1277,7 @@ impl Request {
14571277
return self.is_ws_upgrade_type();
14581278
}
14591279
}
1460-
self.is_http1_1_or_higher_version() || self.is_ws_upgrade_type()
1280+
self.get_version().is_http1_1_or_higher() || self.is_ws_upgrade_type()
14611281
}
14621282

14631283
/// Determines if keep-alive should be disabled for this request.

src/request/test.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ fn request_method_checks() {
141141
method: Method::Get,
142142
..Default::default()
143143
};
144-
assert!(request.is_get_method());
145-
assert!(!request.is_post_method());
146-
assert!(!request.is_put_method());
147-
assert!(!request.is_delete_method());
148-
assert!(!request.is_patch_method());
149-
assert!(!request.is_head_method());
150-
assert!(!request.is_options_method());
151-
assert!(!request.is_connect_method());
152-
assert!(!request.is_trace_method());
153-
assert!(!request.is_unknown_method());
144+
assert!(request.get_method().is_get());
145+
assert!(!request.get_method().is_post());
146+
assert!(!request.get_method().is_put());
147+
assert!(!request.get_method().is_delete());
148+
assert!(!request.get_method().is_patch());
149+
assert!(!request.get_method().is_head());
150+
assert!(!request.get_method().is_options());
151+
assert!(!request.get_method().is_connect());
152+
assert!(!request.get_method().is_trace());
153+
assert!(!request.get_method().is_unknown());
154154
}
155155

156156
#[test]
@@ -159,14 +159,14 @@ fn request_version_checks() {
159159
version: HttpVersion::Http1_1,
160160
..Default::default()
161161
};
162-
assert!(request.is_http1_1_version());
163-
assert!(request.is_http1_1_or_higher_version());
164-
assert!(request.is_http_version());
165-
assert!(!request.is_http0_9_version());
166-
assert!(!request.is_http1_0_version());
167-
assert!(!request.is_http2_version());
168-
assert!(!request.is_http3_version());
169-
assert!(!request.is_unknown_version());
162+
assert!(request.get_version().is_http1_1());
163+
assert!(request.get_version().is_http1_1_or_higher());
164+
assert!(request.get_version().is_http());
165+
assert!(!request.get_version().is_http0_9());
166+
assert!(!request.get_version().is_http1_0());
167+
assert!(!request.get_version().is_http2());
168+
assert!(!request.get_version().is_http3());
169+
assert!(!request.get_version().is_unknown());
170170
}
171171

172172
#[test]

0 commit comments

Comments
 (0)