7

Are urls of the form http://asdf.com/something.do?param1=true?param2=false valid?

I don't think the second ? is allowed in valid urls and that it should instead be an ampersand (&), but I'm unable to find anything about this in the http 1.1 rfc. Any ideas?

4 Answers 4

7

It is not valid to use ? again. ? should indicate the start of the parameter list. & should separate parameters.

From RFC 3986:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

From RFC 1738 :

An HTTP URL takes the form:

http:// <host> : <port> / <path> ? <searchpart>

where <host> and <port> are as described in Section 3.1. If :<port> is omitted, the port defaults to 80. No user name or password is allowed. <path> is an HTTP selector, and <searchpart> is a query string. The <path> is optional, as is the <searchpart> and its preceding "?". If neither <path> nor <searchpart> is present, the "/" may also be omitted.

Within the <path> and <searchpart> components, "/", ";", "?" are reserved. The "/" character may be used within HTTP to designate a hierarchical structure.

The search part/query part is described here.

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

Comments

5

use & for the second and third

i.e. http://asdf.com/something.do?param1=true&param2=false

Comments

1

application/x-www-form-urlencoded

This is the default content type. Forms submitted with this content type must be encoded as follows:

  1. Control names and values are escaped. Space characters are replaced by +, and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by %HH, a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., %0D%0A).
  2. The control names/values are listed in the order they appear in the document. The name is separated from the value by = and name/value pairs are separated from each other by &.

application/x-www-form-urlencoded

Comments

0

As mentioned, it's not valid to use it again. However, if you have the ? character as part of a parameter value, you can encode it as %63 (just like the space character which gets encoded as %20).

Comments

Your Answer

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