Error 503 and %


#1

Some of the links on my site (search.fibis.org links from the search results page) recently stopped working with a 503 error "Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. ".

I have tracked this down to me using % as parameter values in URLs. Take them out and it works fine. This behaviour has only just appeared. Have DreamHost changed some server or php settings anywhere? And is there an easy way to get around it as it’ll be a pig to change all my code.

Thanks

John


#2

It would help if you provided more information. Using % in URI should not cause a problem if you are doing it right:

[code]An escaped octet is encoded as a character triplet, consisting of the
percent character “%” followed by the two hexadecimal digits
representing the octet code. For example, “% 2 0” is the escaped
encoding for the US-ASCII space character.

Because the percent “%” character always has the reserved purpose of
being the escape indicator, it must be escaped as “% 2 5” in order to
be used as data within a URI. Implementers should be careful not to
escape or unescape the same string more than once, since unescaping
an already unescaped string might lead to misinterpreting a percent
data character as another escaped character, or vice versa in the
case of escaping an already escaped string.[/code]That is quoted from
RFC 2396 - Uniform Resource Identifiers (URI): Generic Syntax
PS. Remove the spaces from the sequences in quotes above.
Only thing I can think of might be the mod_security checking for suspiciously encoded URI, unless you are getting the escaping wrong.

EDITED:

OK Found one of the URLs you must be having trouble with:

Yup, the escaping is wrong. The last parameter should be written as

:cool: Perl / MySQL / HTML CSS


#3

[quote]URI should not cause a problem if you are doing it right:
Yup, the escaping is wrong.

[/quote]

OOI, How should that cause the “The server is temporarily unable to service your request due to
maintenance downtime or capacity problems” error?


#4

[quote]OOI, How should that cause the “The server is temporarily unable to service your request due to
maintenance downtime or capacity problems” error?[/quote]
It happens if you put an errant percent character in the query string; in the path it returns the expected 400 Bad Request. Something doesn’t like bad query strings and my guess is the PHP script catching the error but presenting it in a weird way. At least I can not duplicate using a testcase like:

:cool: Perl / MySQL / HTML+CSS


#5

Ah, so the “maintenance or capacity” message is coming from the script, not the server itself?


#6

I’d have to look at the script to answer that question for sure, but it seems that way. It is not impossible for a script to report any type of HTTP error it wants; the important thing is getting the order of the output correct - response headers must go first.

See http://www.php.net/manual/en/function.header.php

All it would take is logic like:

[code]if (decode_query_string() == true) {
header(‘Status: 200 OK’);
/* continue with script */

}
else {
header(‘Status: 503 Temporary unavailable’);
/* exit script */
}[/code]
:cool: Perl / MySQL / HTML+CSS


#7

Aha. Thanks.