0

I could not find anything in the RFC docs about whether the User-Agent field needed to be formatted the way it commonly is. For example, could I just do:

User-Agent: Mozilla windows NT

and still pass a valid request?

2 Answers 2

1

The formal definition of the User-Agent header is defined in RFC 2616 Section 14.43 as follows:

User-Agent     = "User-Agent" ":" 1*( product | comment )

product is defined in Section 3.8 as follows:

product         = token ["/" product-version]
product-version = token

token and comment are defined in Section 2.2 as follows:

token          = 1*<any CHAR except CTLs or separators>
comment        = "(" *( ctext | quoted-pair | comment ) ")"

Whitespace is a separator, so to answer your question, Mozilla windows NT is NOT a valid product by the above token definition. If you want to follow the spec, you could instead format it more like this: Mozilla (Windows NT).

Sign up to request clarification or add additional context in comments.

2 Comments

What if I did Mozilla ((windows NT)), or something derivative. I'm guessing this would be invalid, as parenthesis are key characters here?
Look at the definitions. A comment is delimited by parenthesis, and a comment can contain another comment, thus parenthesis are nestable. So what do you think ((windows NT)) means? A nested comment.
0

Sure, you can 'fake' a user agent. Check for yourself with this tool for instance: https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg

1 Comment

I understand that you can fake a user agent, but this is still keeping the format of the user-agent to the RFC standard. I'm asking whether you can ignore the standard (standard is stated as name of application (comments) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.