views:

283

answers:

5

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?

+1  A: 

use & for the second and third

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

eglasius
+6  A: 

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.

Brian R. Bondy
A: 

Here's the relevant spec.

Hank Gay
Ah thank you. The answer is in sec 2.2 for others reading this (and it looks like they can't be mixed like this)
Section 2.2 doesn't forbid the use of a second question mark. It says that when a delimiting character is used in a context where it's not delimiting, then it's treated as an ordinary character. But RFC 1738 says reserved characters must be encoded, making RFC 3986 irrelevant.
Rob Kennedy
+1  A: 

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

Gumbo
A: 

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).

Josh Stodola