URLs containing spaces


#1

Hi,

I’m having difficulty using URL with urls that contain spaces.
If I use:

I get a 404 ‘http://www.test.com/a’ not found.

If I try:

I get a 404 ‘http://www.test.com/a+test+file.html’ not found.

and finally if I try:

I get a bad request response.

If I remove this from URL::addEscapeChars() it works

if (c == ' ') { result += T('+'); }

but what’s the skinny with ‘+’ representing spaces in URLs? Is that required for the POST part of the request, whereas %20 is needed for the path part?

Any cunning workarounds? Cheers!
graf.


#2

The right solution is URL(“http://www.test.com/a%20test%20file.html”);
From rfc 2396, the allowed char are:

static const tchar reserved[]       = { ';', '/', '?', ':', '@', '&', '=', '+', '$', ',' }; 
static const tchar less_reserved[]  = { ';', ':', '@', '&', '=', '+', '$', ',' }; 
static const tchar unreserved[]     = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 
                                                        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 
                                                        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                                                        '-', '_', '.', '!', '~', '*', '\'', '(', ')' };
static const tchar escaped[]        = { '%', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f' };
static const tchar excluded[]       = { '{', '}', '|', '\\', '^', '[', ']', '`' };     
static const tchar breakScheme[]    = { ':', '/', '?', '#' };

#3