Skip to content

Commit 685fdd9

Browse files
committed
Merge pull request chris-morgan#95 from Ogeon/master
Fixed the tests and cleaned up some warnings
2 parents d161632 + 75423e8 commit 685fdd9

File tree

4 files changed

+85
-82
lines changed

4 files changed

+85
-82
lines changed

src/codegen/status.rs

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ struct Status {
2424
}
2525

2626
/// Status with comment
27-
fn StatusC(code: uint, reason: &'static str, comment: &'static str) -> HeadingOrStatus {
27+
fn status_c(code: uint, reason: &'static str, comment: &'static str) -> HeadingOrStatus {
2828
Status(Status { code: code, reason: reason, comment: Some(comment) })
2929
}
3030

3131
/// Status without comment
32-
fn StatusN(code: uint, reason: &'static str) -> HeadingOrStatus {
32+
fn status_n(code: uint, reason: &'static str) -> HeadingOrStatus {
3333
Status(Status { code: code, reason: reason, comment: None })
3434
}
3535

@@ -74,77 +74,77 @@ pub fn generate(output_dir: &Path) -> IoResult<()> {
7474
let mut out = get_writer(output_dir, "status.rs");
7575
let entries = [
7676
Heading("1xx Informational"),
77-
StatusN(100, "Continue"),
78-
StatusN(101, "Switching Protocols"),
79-
StatusC(102, "Processing", "WebDAV; RFC 2518"),
77+
status_n(100, "Continue"),
78+
status_n(101, "Switching Protocols"),
79+
status_c(102, "Processing", "WebDAV; RFC 2518"),
8080

8181
Heading("2xx Success"),
82-
StatusN(200, "OK"),
83-
StatusN(201, "Created"),
84-
StatusN(202, "Accepted"),
85-
StatusC(203, "Non-Authoritative Information", "since HTTP/1.1"),
86-
StatusN(204, "No Content"),
87-
StatusN(205, "Reset Content"),
88-
StatusN(206, "Partial Content"),
89-
StatusC(207, "Multi-Status", "WebDAV; RFC 4918"),
90-
StatusC(208, "Already Reported", "WebDAV; RFC 5842"),
91-
StatusC(226, "IM Used", "RFC 3229"),
82+
status_n(200, "OK"),
83+
status_n(201, "Created"),
84+
status_n(202, "Accepted"),
85+
status_c(203, "Non-Authoritative Information", "since HTTP/1.1"),
86+
status_n(204, "No Content"),
87+
status_n(205, "Reset Content"),
88+
status_n(206, "Partial Content"),
89+
status_c(207, "Multi-Status", "WebDAV; RFC 4918"),
90+
status_c(208, "Already Reported", "WebDAV; RFC 5842"),
91+
status_c(226, "IM Used", "RFC 3229"),
9292

9393
Heading("3xx Redirection"),
94-
StatusN(300, "Multiple Choices"),
95-
StatusN(301, "Moved Permanently"),
96-
StatusN(302, "Found"),
97-
StatusC(303, "See Other", "since HTTP/1.1"),
98-
StatusN(304, "Not Modified"),
99-
StatusC(305, "Use Proxy", "since HTTP/1.1"),
100-
StatusN(306, "Switch Proxy"),
101-
StatusC(307, "Temporary Redirect", "since HTTP/1.1"),
102-
StatusC(308, "Permanent Redirect", "approved as experimental RFC: http://tools.ietf.org/html/draft-reschke-http-status-308"),
94+
status_n(300, "Multiple Choices"),
95+
status_n(301, "Moved Permanently"),
96+
status_n(302, "Found"),
97+
status_c(303, "See Other", "since HTTP/1.1"),
98+
status_n(304, "Not Modified"),
99+
status_c(305, "Use Proxy", "since HTTP/1.1"),
100+
status_n(306, "Switch Proxy"),
101+
status_c(307, "Temporary Redirect", "since HTTP/1.1"),
102+
status_c(308, "Permanent Redirect", "approved as experimental RFC: http://tools.ietf.org/html/draft-reschke-http-status-308"),
103103

104104
Heading("4xx Client Error"),
105-
StatusN(400, "Bad Request"),
106-
StatusN(401, "Unauthorized"),
107-
StatusN(402, "Payment Required"),
108-
StatusN(403, "Forbidden"),
109-
StatusN(404, "Not Found"),
110-
StatusN(405, "Method Not Allowed"),
111-
StatusN(406, "Not Acceptable"),
112-
StatusN(407, "Proxy Authentication Required"),
113-
StatusN(408, "Request Timeout"),
114-
StatusN(409, "Conflict"),
115-
StatusN(410, "Gone"),
116-
StatusN(411, "Length Required"),
117-
StatusN(412, "Precondition Failed"),
118-
StatusN(413, "Request Entity Too Large"),
119-
StatusN(414, "Request-URI Too Long"),
120-
StatusN(415, "Unsupported Media Type"),
121-
StatusN(416, "Requested Range Not Satisfiable"),
122-
StatusN(417, "Expectation Failed"),
123-
StatusC(418, "I'm a teapot", "RFC 2324"),
124-
StatusN(419, "Authentication Timeout"),
125-
StatusC(422, "Unprocessable Entity", "WebDAV; RFC 4918"),
126-
StatusC(423, "Locked", "WebDAV; RFC 4918"),
127-
StatusC(424, "Failed Dependency", "WebDAV; RFC 4918"),
128-
StatusC(424, "Method Failure", "WebDAV"),
129-
StatusC(425, "Unordered Collection", "Internet draft"),
130-
StatusC(426, "Upgrade Required", "RFC 2817"),
131-
StatusC(428, "Precondition Required", "RFC 6585"),
132-
StatusC(429, "Too Many Requests", "RFC 6585"),
133-
StatusC(431, "Request Header Fields Too Large", "RFC 6585"),
134-
StatusC(451, "Unavailable For Legal Reasons", "Internet draft"),
105+
status_n(400, "Bad Request"),
106+
status_n(401, "Unauthorized"),
107+
status_n(402, "Payment Required"),
108+
status_n(403, "Forbidden"),
109+
status_n(404, "Not Found"),
110+
status_n(405, "Method Not Allowed"),
111+
status_n(406, "Not Acceptable"),
112+
status_n(407, "Proxy Authentication Required"),
113+
status_n(408, "Request Timeout"),
114+
status_n(409, "Conflict"),
115+
status_n(410, "Gone"),
116+
status_n(411, "Length Required"),
117+
status_n(412, "Precondition Failed"),
118+
status_n(413, "Request Entity Too Large"),
119+
status_n(414, "Request-URI Too Long"),
120+
status_n(415, "Unsupported Media Type"),
121+
status_n(416, "Requested Range Not Satisfiable"),
122+
status_n(417, "Expectation Failed"),
123+
status_c(418, "I'm a teapot", "RFC 2324"),
124+
status_n(419, "Authentication Timeout"),
125+
status_c(422, "Unprocessable Entity", "WebDAV; RFC 4918"),
126+
status_c(423, "Locked", "WebDAV; RFC 4918"),
127+
status_c(424, "Failed Dependency", "WebDAV; RFC 4918"),
128+
status_c(424, "Method Failure", "WebDAV"),
129+
status_c(425, "Unordered Collection", "Internet draft"),
130+
status_c(426, "Upgrade Required", "RFC 2817"),
131+
status_c(428, "Precondition Required", "RFC 6585"),
132+
status_c(429, "Too Many Requests", "RFC 6585"),
133+
status_c(431, "Request Header Fields Too Large", "RFC 6585"),
134+
status_c(451, "Unavailable For Legal Reasons", "Internet draft"),
135135

136136
Heading("5xx Server Error"),
137-
StatusN(500, "Internal Server Error"),
138-
StatusN(501, "Not Implemented"),
139-
StatusN(502, "Bad Gateway"),
140-
StatusN(503, "Service Unavailable"),
141-
StatusN(504, "Gateway Timeout"),
142-
StatusN(505, "HTTP Version Not Supported"),
143-
StatusC(506, "Variant Also Negotiates", "RFC 2295"),
144-
StatusC(507, "Insufficient Storage", "WebDAV; RFC 4918"),
145-
StatusC(508, "Loop Detected", "WebDAV; RFC 5842"),
146-
StatusC(510, "Not Extended", "RFC 2774"),
147-
StatusC(511, "Network Authentication Required", "RFC 6585"),
137+
status_n(500, "Internal Server Error"),
138+
status_n(501, "Not Implemented"),
139+
status_n(502, "Bad Gateway"),
140+
status_n(503, "Service Unavailable"),
141+
status_n(504, "Gateway Timeout"),
142+
status_n(505, "HTTP Version Not Supported"),
143+
status_c(506, "Variant Also Negotiates", "RFC 2295"),
144+
status_c(507, "Insufficient Storage", "WebDAV; RFC 4918"),
145+
status_c(508, "Loop Detected", "WebDAV; RFC 5842"),
146+
status_c(510, "Not Extended", "RFC 2774"),
147+
status_c(511, "Network Authentication Required", "RFC 6585"),
148148
];
149149
unsafe {
150150
longest_ident = entries.iter().map(|&e| match e {

src/http/headers/content_type.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ pub struct MediaType {
1010
pub parameters: Vec<(String, String)>,
1111
}
1212

13-
pub fn MediaType(type_: String, subtype: String, parameters: Vec<(String, String)>) -> MediaType {
14-
MediaType {
15-
type_: type_,
16-
subtype: subtype,
17-
parameters: parameters,
13+
impl MediaType {
14+
pub fn new(type_: String, subtype: String, parameters: Vec<(String, String)>) -> MediaType {
15+
MediaType {
16+
type_: type_,
17+
subtype: subtype,
18+
parameters: parameters,
19+
}
1820
}
1921
}
2022

23+
24+
2125
impl fmt::Show for MediaType {
2226
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2327
// Idea:
@@ -75,13 +79,13 @@ impl super::HeaderConvertible for MediaType {
7579
fn test_content_type() {
7680
use headers::test_utils::{assert_conversion_correct, assert_interpretation_correct,
7781
assert_invalid};
78-
assert_conversion_correct("type/subtype", MediaType(String::from_str("type"), String::from_str("subtype"), Vec::new()));
82+
assert_conversion_correct("type/subtype", MediaType::new(String::from_str("type"), String::from_str("subtype"), Vec::new()));
7983
assert_conversion_correct("type/subtype;key=value",
80-
MediaType(String::from_str("type"), String::from_str("subtype"), vec!((String::from_str("key"), String::from_str("value")))));
84+
MediaType::new(String::from_str("type"), String::from_str("subtype"), vec!((String::from_str("key"), String::from_str("value")))));
8185
assert_conversion_correct("type/subtype;key=value;q=0.1",
82-
MediaType(String::from_str("type"), String::from_str("subtype"), vec!((String::from_str("key"), String::from_str("value")), (String::from_str("q"), String::from_str("0.1")))));
86+
MediaType::new(String::from_str("type"), String::from_str("subtype"), vec!((String::from_str("key"), String::from_str("value")), (String::from_str("q"), String::from_str("0.1")))));
8387
assert_interpretation_correct("type/subtype ; key = value ; q = 0.1",
84-
MediaType(String::from_str("type"), String::from_str("subtype"), vec!((String::from_str("key"), String::from_str("value")), (String::from_str("q"), String::from_str("0.1")))));
88+
MediaType::new(String::from_str("type"), String::from_str("subtype"), vec!((String::from_str("key"), String::from_str("value")), (String::from_str("q"), String::from_str("0.1")))));
8589

8690
assert_invalid::<MediaType>("");
8791
assert_invalid::<MediaType>("/");

src/http/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
#![feature(default_type_params)]
1414
#![feature(macro_rules)]
1515
#![feature(phase)]
16-
#![macro_escape]
1716

18-
#[phase(syntax, link)] extern crate log;
17+
#[phase(plugin, link)] extern crate log;
1918
extern crate url;
2019
extern crate time;
2120
extern crate collections;

src/http/memstream.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ mod test {
9494
fn test_mem_reader_fake_stream() {
9595
let mut reader = MemReaderFakeStream::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
9696
let mut buf = vec![];
97-
assert_eq!(reader.read(buf), Ok(0));
97+
assert_eq!(reader.read(buf.as_mut_slice()), Ok(0));
9898
assert_eq!(reader.tell(), Ok(0));
9999
let mut buf = vec![0];
100-
assert_eq!(reader.read(buf), Ok(1));
100+
assert_eq!(reader.read(buf.as_mut_slice()), Ok(1));
101101
assert_eq!(reader.tell(), Ok(1));
102102
assert_eq!(buf, vec![0]);
103103
let mut buf = vec![0, 0, 0, 0];
104-
assert_eq!(reader.read(buf), Ok(4));
104+
assert_eq!(reader.read(buf.as_mut_slice()), Ok(4));
105105
assert_eq!(reader.tell(), Ok(5));
106-
assert_eq!(buf, vec[1, 2, 3, 4]);
107-
assert_eq!(reader.read(buf), Ok(3));
106+
assert_eq!(buf, vec![1, 2, 3, 4]);
107+
assert_eq!(reader.read(buf.as_mut_slice()), Ok(3));
108108
assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
109-
assert_eq!(reader.read(buf).ok(), None);
109+
assert_eq!(reader.read(buf.as_mut_slice()).ok(), None);
110110
}
111111
}

0 commit comments

Comments
 (0)