proptest_http/
lib.rs

1#![forbid(unsafe_code)]
2
3//! `impl proptest::Arbitrary for http::{Request,Response,Uri};`
4//!
5//! This crate contains the code to generate random-ish `http` objects:
6//! urls, requests, headers, responses
7//!
8//! It is rather simple and straightforward:
9//! most things are just chosen from a static list
10//!
11//! To be useful for your project, you may want to fork it and
12//! modify the arrays.
13//!
14//! Example URL simplification sequence:
15//!
16//! ```norust
17//! * `https://6:%5B%5D%3F%2F%3C%7E%23%6D%21%40%24%25%5E%26%2A%28%29%2B%3D%7D%7C%3A%22%3B%27%2C%3E%7B%20@example.com:8080/foo/bar/?q=http%3A%2F%2F%5B%3A%3A1%5D%3A123%2F%3Fqw%3D3%26q%3D1%231v&`
18//! * `http://6:%5B%5D%3F%2F%3C%7E%23%6D%21%40%24%25%5E%26%2A%28%29%2B%3D%7D%7C%3A%22%3B%27%2C%3E%7B%20@example.com:8080/foo/bar/?q=http%3A%2F%2F%5B%3A%3A1%5D%3A123%2F%3Fqw%3D3%26q%3D1%231v&`
19//! * `http://%20:%20@example.com:8080/foo/bar/?q=http%3A%2F%2F%5B%3A%3A1%5D%3A123%2F%3Fqw%3D3%26q%3D1%231v&`
20//! * `http://%20:%20@example.com:8080/foo?q=http%3A%2F%2F%5B%3A%3A1%5D%3A123%2F%3Fqw%3D3%26q%3D1%231v&`
21//! * `http://%20:%20@example.com:8080/foo?q=w`
22//! * `/foo?q=w`
23//! * `/?q=w `
24//! * `/?`
25//! ```
26//!
27//! Example of a request (I know that header names and values are not congruent):
28//!
29//! ```norust
30//! Request {
31//!     method: DELETE,
32//!     uri: /,
33//!     version: HTTP/1.1,
34//!     headers: {
35//!         "dnt": "keep-alive",
36//!         "host": "999999999999999999999999999999999999999999999999999999",
37//!         "date": "websocket",
38//!         "authorization": "close",
39//!         "upgrade": "%",
40//!         "connection": "deflate",
41//!         "content-type": "Thu, 20 Jun 2019 21:06:20 GMT",
42//!         "cache-control": "\r\n",
43//!         "expires": "	",
44//!         "user-agent": "localhost",
45//!         "content-length": "%",
46//!         "server": "max-age=604800",
47//!         "accept": "_xsrf=2|8bea5404|5ef47a59a0516e67bbd5f86849e28a1c|1553532280",
48//!         "accept-encoding": "text/html",
49//!         "accept-language": "websocket",
50//!     },
51//!     body: (),
52//! }
53
54//! ```
55
56pub extern crate http;
57pub extern crate proptest;
58
59use proptest::arbitrary::Arbitrary;
60use proptest::bool::{weighted, BoolValueTree};
61use proptest::collection::VecValueTree;
62use proptest::sample::{Index, IndexValueTree};
63use proptest::strategy::{NewTree, Strategy, ValueTree};
64use proptest::test_runner::TestRunner;
65use proptest::tuple::TupleValueTree;
66
67pub mod uri;
68pub use uri::ArbitraryUri;
69
70pub mod request;
71pub use request::{ArbitraryMethod, ArbitraryRequest};
72
73pub mod header;
74pub use header::{ArbitraryHeaderMap, ArbitraryHeaderName, ArbitraryHeaderValue};
75
76pub mod response;
77pub use response::{ArbitraryResponse, ArbitraryStatusCode};