neqo icon indicating copy to clipboard operation
neqo copied to clipboard

check that - for a request, we DON'T get :status?

Open ddragana opened this issue 3 years ago • 0 comments

I know that this is old code, but shouldn't we be checking that - for a request, we DON'T get :status?

That means we need a set of bits that should be on and a set of bits that should be off. Or:

        const PSEUDO_HEADER_ALL: u8 = PSEUDO_HEADER_STATUS | PSEUDO_HEADER_METHOD | PSEUDO_HEADER_SCHEME | PSEUDO_HEADER_AUTHORITY | PSEUDO_HEADER_PATH;
        let (ph_required, ph_mask) = match message_type {
             // Responses contain only :status
             MessageType::Response => (PSEUDO_HEADER_STATUS, PSEUDO_HEADER_ALL),
            MessageType::Request => {
                if method_value == Some(&"CONNECT".to_string()) {
                    // CONNECT requests contain only :method and :authority
                    // This won't work once we get to :protocol...
                    (PSEUDO_HEADER_METHOD | PSEUDO_HEADER_AUTHORITY, PSEUDO_HEADER_ALL)
                } else {
                    // Other requests contain :method, :scheme, and :path, and may contain :authority.
                    (PSEUDO_HEADER_METHOD | PSEUDO_HEADER_SCHEME | PSEUDO_HEADER_PATH, PSEUDO_HEADER_ALL & !PSEUDO_HEADER_AUTHORITY)
                }
            }
        };
        if pseudo_state & ph_mask != ph_required {
            return Err(Error::InvalidHeader);
        }

Originally posted by @martinthomson in https://github.com/mozilla/neqo/pull/1270#discussion_r755542245

ddragana avatar Nov 24 '21 06:11 ddragana