Skip to content

Commit 062e5ff

Browse files
committed
Rename new to parsed on partial request
1 parent 53bec8e commit 062e5ff

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/models/partial_request.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl fmt::Display for PartialHttpRequest {
2626
}
2727

2828
impl PartialHttpRequest {
29-
pub fn new(
29+
pub fn parsed(
3030
message: &str,
3131
method: Option<Range<usize>>,
3232
uri: Option<Range<usize>>,
@@ -195,7 +195,7 @@ where
195195
F: Fn(&str) -> FirstLineParts,
196196
{
197197
if input.trim().is_empty() {
198-
return Ok(PartialHttpRequest::new(
198+
return Ok(PartialHttpRequest::parsed(
199199
input,
200200
None,
201201
None,
@@ -220,7 +220,7 @@ where
220220

221221
let body_span = get_span_extent_from_spans(body_spans);
222222

223-
Ok(PartialHttpRequest::new(
223+
Ok(PartialHttpRequest::parsed(
224224
input,
225225
method,
226226
uri,
@@ -300,31 +300,31 @@ mod tests {
300300
#[test]
301301
#[should_panic]
302302
fn verifies_out_of_bounds_method_span() {
303-
PartialHttpRequest::new("", Some(1..2), None, None, vec![], None);
303+
PartialHttpRequest::parsed("", Some(1..2), None, None, vec![], None);
304304
}
305305

306306
#[test]
307307
#[should_panic]
308308
fn verifies_inverted_method_span() {
309-
PartialHttpRequest::new("", Some(2..1), None, None, vec![], None);
309+
PartialHttpRequest::parsed("", Some(2..1), None, None, vec![], None);
310310
}
311311

312312
#[test]
313313
#[should_panic]
314314
fn verifies_out_of_bounds_uri_span() {
315-
PartialHttpRequest::new("", None, Some(1..2), None, vec![], None);
315+
PartialHttpRequest::parsed("", None, Some(1..2), None, vec![], None);
316316
}
317317

318318
#[test]
319319
#[should_panic]
320320
fn verifies_inverted_uri_span() {
321-
PartialHttpRequest::new("", None, Some(2..1), None, vec![], None);
321+
PartialHttpRequest::parsed("", None, Some(2..1), None, vec![], None);
322322
}
323323

324324
#[test]
325325
#[should_panic]
326326
fn verifies_method_span_overlaps_uri_span() {
327-
PartialHttpRequest::new(
327+
PartialHttpRequest::parsed(
328328
"GET https://example.com",
329329
Some(0..3),
330330
Some(2..10),
@@ -337,45 +337,45 @@ mod tests {
337337
#[test]
338338
#[should_panic]
339339
fn verifies_out_of_bounds_http_version_span() {
340-
PartialHttpRequest::new("", None, None, Some(1..2), vec![], None);
340+
PartialHttpRequest::parsed("", None, None, Some(1..2), vec![], None);
341341
}
342342

343343
#[test]
344344
#[should_panic]
345345
fn verifies_inverted_http_version_span() {
346-
PartialHttpRequest::new("", None, None, Some(2..1), vec![], None);
346+
PartialHttpRequest::parsed("", None, None, Some(2..1), vec![], None);
347347
}
348348

349349
#[test]
350350
#[should_panic]
351351
fn verifies_out_of_bounds_header_span() {
352-
PartialHttpRequest::new("", None, None, None, vec![1..2], None);
352+
PartialHttpRequest::parsed("", None, None, None, vec![1..2], None);
353353
}
354354

355355
#[test]
356356
#[should_panic]
357357
fn verifies_inverted_header_span() {
358-
PartialHttpRequest::new("", None, None, None, vec![2..1], None);
358+
PartialHttpRequest::parsed("", None, None, None, vec![2..1], None);
359359
}
360360

361361
#[test]
362362
#[should_panic]
363363
fn verifies_out_of_bounds_body_span() {
364-
PartialHttpRequest::new("", None, None, None, vec![], Some(1..2));
364+
PartialHttpRequest::parsed("", None, None, None, vec![], Some(1..2));
365365
}
366366

367367
#[test]
368368
#[should_panic]
369369
fn verifies_inverted_body_span() {
370-
PartialHttpRequest::new("", None, None, None, vec![], Some(2..1));
370+
PartialHttpRequest::parsed("", None, None, None, vec![], Some(2..1));
371371
}
372372

373373
#[test]
374374
fn implements_default() {
375375
let partial = PartialHttpRequest::default();
376376

377377
assert_eq!(
378-
PartialHttpRequest::new(
378+
PartialHttpRequest::parsed(
379379
"GET https://example.com HTTP/1.1",
380380
Some(0..3),
381381
Some(4..23),

src/models/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ mod from_partial_request_tests {
124124

125125
#[test]
126126
fn from_partial_request_get() {
127-
let partial_request = PartialHttpRequest::new(
127+
let partial_request = PartialHttpRequest::parsed(
128128
r#"
129129
GET https://example.com HTTP/1.1
130130
x-api-key: abc123

tests/parse_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn parse_empty_request() {
1313
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
1414

1515
assert_eq!(
16-
PartialHttpRequest::new(&content, None, None, None, vec![], None),
16+
PartialHttpRequest::parsed(&content, None, None, None, vec![], None),
1717
partial
1818
);
1919
}
@@ -26,7 +26,7 @@ fn parse_whitespace_request() {
2626
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
2727

2828
assert_eq!(
29-
PartialHttpRequest::new(&content, None, None, None, vec![], None),
29+
PartialHttpRequest::parsed(&content, None, None, None, vec![], None),
3030
partial
3131
);
3232
}
@@ -39,7 +39,7 @@ fn parse_get_request() {
3939
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
4040

4141
assert_eq!(
42-
PartialHttpRequest::new(
42+
PartialHttpRequest::parsed(
4343
include_str!("../tests/fixtures/get.request"),
4444
Some(0..3),
4545
Some(4..23),
@@ -72,7 +72,7 @@ fn parse_get_without_http_version_request() {
7272
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
7373

7474
assert_eq!(
75-
PartialHttpRequest::new(
75+
PartialHttpRequest::parsed(
7676
include_str!("../tests/fixtures/get_without_http_version.request"),
7777
Some(0..3),
7878
Some(4..23),
@@ -105,7 +105,7 @@ fn parse_get_with_headers_request() {
105105
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
106106

107107
assert_eq!(
108-
PartialHttpRequest::new(
108+
PartialHttpRequest::parsed(
109109
include_str!("../tests/fixtures/get_with_headers.request"),
110110
Some(0..3),
111111
Some(4..23),
@@ -144,7 +144,7 @@ fn parse_post_with_headers_and_body_request() {
144144
let body = Some(53..64);
145145

146146
assert_eq!(
147-
PartialHttpRequest::new(&content, method, uri, http_version, headers, body),
147+
PartialHttpRequest::parsed(&content, method, uri, http_version, headers, body),
148148
partial
149149
);
150150

@@ -170,7 +170,7 @@ fn parse_post_with_body_request() {
170170
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
171171

172172
assert_eq!(
173-
PartialHttpRequest::new(
173+
PartialHttpRequest::parsed(
174174
include_str!("../tests/fixtures/post_with_body.request"),
175175
Some(0..4),
176176
Some(5..24),
@@ -203,7 +203,7 @@ fn parse_get_with_multiple_spaces_request() {
203203
let partial = PartialHttpRequest::from_str(&content).expect("should be parsable");
204204

205205
assert_eq!(
206-
PartialHttpRequest::new(
206+
PartialHttpRequest::parsed(
207207
&content,
208208
Some(0..3),
209209
Some(5..24),

0 commit comments

Comments
 (0)