rust-http icon indicating copy to clipboard operation
rust-http copied to clipboard

Case sensitivity of methods, and spec compliance

Open Manishearth opened this issue 10 years ago • 2 comments

While from_str in method.rs currently mentions that it is case insensitive, the code reads otherwise. This probably should be fixed.

Additionally, the rules for extension methods probably should match the token production given here, and fail or return None otherwise.

(I'll try my hand at this)

Manishearth avatar May 09 '14 01:05 Manishearth

The rules for a valid token for extension methods can use the following method on a Vec<u8>:

        vec.iter().all(|&x| {
            // http://tools.ietf.org/html/rfc2616#section-2.2
            match x {
                0..31 | 127 => false, // CTLs
                40 | 41 | 60 | 62 | 64 |
                44 | 59 | 58 | 92 | 34 |
                47 | 91 | 93 | 63 | 61 |
                123 | 125 | 32  => false, // separators
                _ => true
            }
        })
    }

Manishearth avatar May 09 '14 02:05 Manishearth

Actually, case sensitive was correct; the comment is the thing at fault.

I quite agree about ensuring that the parsing is done correctly; that’s something that should be fixed at the type level, really; in this one place is not optimal.

Frankly, I wouldn’t bother about changing these things; rust-http is in maintenance mode, with new work taking place on Teepee. There, such compliance is being taken seriously.

chris-morgan avatar May 09 '14 04:05 chris-morgan