0
votes

I get this weird behaviour from all browsers when trying to send this form. This form has only 2 fields, a title and the article body. The form defaults to application/x-www-form-urlencoded. When submitted the site sometimes responds with a 404.

The log below is taken directly from Live HTTP Headers.

http://www.faulty-domain.com/article-page  

POST /article-page HTTP/1.1  
Host: www.faulty-domain.com  
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.23) Gecko/20110920   Firefox/3.6.23 ( .NET CLR 3.5.30729)  
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
Accept-Language: en-us,en;q=0.5  
Accept-Encoding: gzip,deflate  
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7  
Keep-Alive: 115  
Connection: keep-alive  
Referer: http://www.faulty-domain.com/article-page  
Content-Type: application/x-www-form-urlencoded  
Content-Length: 3288  
blog_title=Article+Title+to+save&newsbody=%3Cp%3EThe+current+blah+blah+blah%3C%2Fp%3E  


HTTP/1.1 302 Found  
Date: Tue, 08 Nov 2011 12:42:23 GMT  
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5   mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.14  
X-Powered-By: PHP/5.2.14  
Expires: Thu, 19 Nov 1981 08:52:00 GMT  
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0  
Pragma: no-cache  
Location: http://www.faulty-domain.com/notFound  
Content-Encoding: gzip  
Vary: Accept-Encoding  
Content-Length: 26  
Connection: close  
Content-Type: text/html

The page tries to send to itself, then is suppose to check if the method was post and various validation checks, the usual stuff. But then, the http response is a 404 not found page.

Our internal framework works like Code Igniter, such that all request will execute index.php. Clearly the web server did not even try to execute index.php, but decided based on the request headers somehow that the response should be a 404.

Now I've done my own debugging, and played with the article I'm sending. I tried to append the article paragraph by paragraph and see on what paragraph the bug triggers. The form submits fine until a certain paragraph, at that point I said Bingo! I thought I isolated the problem and tried to submit the form using that paragraph alone, but then the form submitted. Which now puzzles me, why would the web server accept it as it is, but if appended on the end of the original article, it goes nuts!

It's probably an htaccess thing, or a web server thing, but I just couldn't get this thing nailed.

Update:

For all those that requested to view the post data being sent, heres a link. I will delete the file after a week or so. http://www.globalpropertyguide.com/temp/faulty-article.html

Here is a piece of the htaccess that might help. Basically our index.php determines what controller to call based on what value $mod receives.

RewriteRule ^([^/]+)/$ /$1 [R]
RewriteCond %{QUERY_STRING} !mod= [NC]
RewriteRule ^([^/]+)$ /index.php?mod=$1 [L]

Also, if ever it might help, this is the error that gets log on apache error_log

"POST /write-article HTTP/1.1" 302 26 "http://www.faulty-domain.com/write-article" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.24) Gecko/20111103 Firefox/3.6.24 ( .NET CLR 3.5.30729)"
"GET /notFound HTTP/1.1" 404 7635 "http://www.faulty-domain.com/write-article" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.24) Gecko/20111103 Firefox/3.6.24 ( .NET CLR 3.5.30729)"
1
@Phil, Indeed, but if we look closer on the Response Header Section, the Location is a notfound page. I pressume, when the server decided there's something wrong with the request, it redirected the request to 404. I could be wrong. - foxlance
What does the .htaccess look like? Is it possible that the framework is the one initiating the redirect? There's not a lot to go off of "works like Code Igniter". - nachito
@nachito, I've added some information that might help further the problem - foxlance

1 Answers

0
votes

You have to find out who is redirecting you, and why. It would really help if you simply update your question with the body you're trying to post that goes wrong, and a body of equal size that gets accepted.

It might happen in PHP. There may be some kind of checking for length, or bad words, that does a faulty redirect. There also might be some kind of Apache plugin active that does the same.