logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Odd Header Behavior Page 1, 2  Next
Author
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Thu 17 May '07 13:45    Post subject: Odd Header Behavior Reply with quote

running Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 Perl/v5.8.8

We get an intermittent error where a random letter/number combination will be inserted between the response headers and the page header.

Code:

HTTP/1.1 200 OK
Date: Thu, 17 May 2007 11:44:21 GMT
Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 Perl/v5.8.8
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

1db1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


This happens more often when the server is under load, but also can happen when it is not. It causes the page to not be rendered by the browser. If you refresh the page it will usually refresh fine without the random letter/number and will then render fine. Has anyone seen this before?
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 17 May '07 15:10    Post subject: Reply with quote

This appears to be chunked encoding.
The 1db1 indicates that the follwing section of the message body is 7,601 bytes long (7601 decimal = 1db1 hexadecimal).

The problem is that there is no:
    Transfer-Encoding: chunked
header to indicate that chunked encoding is being used.

Your Apache and mod_perl are versions from 2005.
You might try more recent versions of Apache (version 2.0.59 was released July 28, 2006) and mod_perl (version 2.0.3 was released November 28, 2006).

-tom-
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Thu 17 May '07 16:14    Post subject: Reply with quote

Where is chunked-encoding usually defined in the server config?

Quote:
Your Apache and mod_perl are versions from 2005.
You might try more recent versions of Apache (version 2.0.59 was released July 28, 2006) and mod_perl (version 2.0.3 was released November 28, 2006).

Yeah...the company who provides our ERP solution only supports versions of apache that they release. They control it by not providing the source code to some of their proprietary interfaces between apache perl and C. We will be creating our own interface soon and will be able to choose our version of apache soon hopefully, but for now we are stuck. (and what is sad is we just upgraded to this version last november, prior to that it was apache1.3 and perl 5.6)
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 17 May '07 16:34    Post subject: Reply with quote

Chunked encoding is not defined or controlled in the server config.

It is automatic (per RFC2616) if the client browser supports HTTP 1.1 and uses KeepAlive.
Most modern browsers do.

You might try adjusting your KeepAlive parameters.

If this problem always happens on the 100th request from a browser, you could set MaxKeepAliveRequests to 0 (which means "unlimited").
It is currently 100 - which is the default if you do not specify it.

Another one to try is KeepAliveTimeout . The Apache 2.0 default is 15 seconds, but a value like 5 may work better for you.

-tom-

p.s. Once you can freely choose your version of Apache, I suggest you move to Apache 2.2.
The current release, 2.2.4, is surprisingly stable with heavy volume.
The downside is that all modules must be re-built for Apache 2.2 vs. 2.0.
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Thu 17 May '07 17:02    Post subject: Reply with quote

when i change the first display lines from:
Code:

Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

To:
Code:

Transfer-Encoding: chunked
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


the page doesn't load, doesn't error, and whatever page i am currently on doesn't dissapear either, and it says its done. Is there an order to this or something i am missing?
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 17 May '07 17:28    Post subject: Reply with quote

When you have Transfer-Encoding: chunked, you need the hex length (like 1db1). Chunked encoding won't work without it.

Looking at the source code for Apache 2.0.55 - it seems impossible for Apache to perform chunked-encoding without sending the Transfer-Encoding: chunked header.

Does your provider supply an altered version of Apache 2.0.55?

Another possibility is that they perform the chunked encoding in Perl (vs. letting Apache do it) and neglect to add the header.
This seems pretty unlikely though!

FYI - If you look at the Apache 2.0.55 source code for http_protocol.c:
    at line 1667 - the Transfer-Encoding header is added if r->chunked is true
    (and any Content-Length header is removed)

    at line 1753 - the chunked encoding filter is enabled if r->chunked is true

It's hard to see how you ever get chunked encoding without the header.
The value of r->chunked is not changed between lines 1667 and 1753.

Very curious! Maybe I'm missing something. Does your Apache config use any Proxy... directives?

-tom-
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Thu 17 May '07 17:51    Post subject: Reply with quote

Heh, oddly enough the transfer encoding has been chunked all along, the program i was using to get the header information out conveniently was stripping it out. So no idea then why it happens. In any case i have changed the keepalive stuff and we will see if that cleans up the problem.

Thanks for your time.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 17 May '07 17:59    Post subject: Reply with quote

No sweat! An interesting problem.

If changing the two directives doesn't work, you could turn KeepAlives (and therefore chunked encoding) off completely with:
Code:
KeepAlive Off


This is pretty extreme. It will cost you considerable performance, but if it corrects the problem it will show that we are on the right track.

If it doesn't work, then KeepAlive & chunked-encoding weren't the root problem after all.

When you get a non-rendered page - try View Source in the browser and see if that shows anythng.

-tom-
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Fri 18 May '07 13:22    Post subject: Reply with quote

I guess then i will have to try turning keepalive off at this point because it has appeared again. Interestingly enough view source does not show the chunk numbers even though they are displayed on the non-rendered page.


Code:
HTTP/1.1 200 OK
Date: Fri, 18 May 2007 11:13:48 GMT
Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 Perl/v5.8.8
Keep-Alive: timeout=5, max=499
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

2714
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

...
Code:
<center><input type="submit" name="command" value="Next"></center></form>
20b
</div>

...
Code:
</div>
</body>
</html>

0


Now from what i understand about reading about chunks is that this all should be working fine or at the very least what is being sent to the browser is the correct codes for it to interpret the chunks.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 18 May '07 15:01    Post subject: Reply with quote

Correct - View Source does not show the chunks - they have already been reassembled. It does not show headers either.

The question is: when you get the page which is not rendered (a blank white page?) - what does View Source show? Anything?

-tom-
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Fri 18 May '07 15:20    Post subject: Reply with quote

Oh, no when i say not rendered i mean the browser (any browser) doesn't turn the html into something pretty. All lines of code are printed on the screen in plain text, view source shows the same as on the screen minus the http header information and the chunk information. Sorry for the confusion.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 18 May '07 16:13    Post subject: Reply with quote

Maybe you are missing the Content-Type header when this happens, and the browser is mis-interpreting the response as plain text instead of text/html.

In FireFox, you can use Tools Page-Info to check whether the Content-Type is really text/html.
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Fri 18 May '07 16:18    Post subject: Reply with quote

Well that makes no sense when the header that is printed plainly says Content-Type: text/html. note that when the page doesn't render the page-info says the type is text/plain. The thing i don't understand is why its intermittent. If i refresh a page that has this problem then it reloads fine and renders fine.

Here is a copy of exactly what prints to the screen when this happens.

https://cars.bethelcollege.edu/huh.txt
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 18 May '07 16:56    Post subject: Reply with quote

Anything which prints to the browser screen is not considered a header.
I suspect if you examine Tools Page-Info you will find that the browser thinks it is plain text, not text/html. EDIT: ooops! you just said that, didn't you.

The browser is apparently getting a blank line ahead of the "HTTP/1.1 200 OK" line
- so "HTTP/1.1 200 OK" and everything after it are not recognized as headers, but are incorrectly treated as the body of the response.

This shouldn't happen. The "HTTP/1.1 200 OK" line should be the very first thing the browser receives. No blank lines should precede it.

Do you have any 3rd-party modules installed, other than mod_perl?
If so, you could try temporarily disabling them.

If you use mod_deflate, it may be worth commenting that out too.

-tom-

EDIT: Just a thought - are you using FireFox 2.0.0.3? Does this happen with other browsers?
There's a small possibility this might be a browser bug, not an Apache bug.
I don't see any relevant Closed Apache bugs for Apache 2.0
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Fri 18 May '07 18:24    Post subject: Reply with quote

I found a plugin for firefox that lets me capture all of the headers sent and recieved:
below is an sdiff of them. On the left is the one that fails and on the right the one that works. There are no differences on the page or how i arrived at the page. You may have to copy it into notepad for it to format right though.
Code:
https://cars.bethelcollege.edu/auth/common/ids.cgi                 https://cars.bethelcollege.edu/auth/common/ids.cgi

POST /auth/common/ids.cgi HTTP/1.1                                 POST /auth/common/ids.cgi HTTP/1.1
Host: cars.bethelcollege.edu                                       Host: cars.bethelcollege.edu
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv     User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8
Accept: text/xml,application/xml,application/xhtml+xml,text/ht     Accept: text/xml,application/xml,application/xhtml+xml,text/html;q
Accept-Language: en-us,en;q=0.5                                    Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate                                      Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7                     Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300                                                    Keep-Alive: 300
Connection: keep-alive                                             Connection: keep-alive
Referer: https://cars.bethelcollege.edu/auth/faculty/stuadv/ma     Referer: https://cars.bethelcollege.edu/auth/faculty/stuadv/main.c
Content-Type: application/x-www-form-urlencoded                    Content-Type: application/x-www-form-urlencoded
Content-Length: 97                                                 Content-Length: 97
user_id=264445&id=333014&callingscp=%2Fauth%2Ffaculty%2Fstuadv     user_id=264445&id=333014&callingscp=%2Fauth%2Ffaculty%2Fstuadv%2Fm
HTTP/1.x 200 OK                                                    HTTP/1.x 200 OK
                                                                >  Date: Fri, 18 May 2007 16:00:24 GMT
                                                                >  Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.8a mod_per
                                                                >  Keep-Alive: timeout=5, max=500
                                                                >  Connection: Keep-Alive
                                                                >  Transfer-Encoding: chunked
                                                                >  Content-Type: text/html


Additionally i have not been able to replicate the error in IE7, but that is not to say that it doesn't happen, i just can't make it happen.

Edit:I am not using any other mods, in fact, although mod_perl is installed we aren't using that either....again problems with the interface code.


Last edited by iamwyza on Fri 18 May '07 19:00; edited 1 time in total
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 18 May '07 18:58    Post subject: Reply with quote

One important thing - posting the Authorization: header is not a good idea.
Basic Authentication is not resistant to network evesdropping (or public posting).

You should change the password for wyzaj immediately.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 18 May '07 19:14    Post subject: Reply with quote

The "HTTP/1.x 200 OK" line is funny.
It should be "HTTP/1.1 200 OK".

Any idea where that 1.x comes from?
I don't think Apache 2.0.55 can generate non-numeric protocol version numbers like this.
Maybe something in your application? A grep for '1.x' might turn something up.
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Fri 18 May '07 19:27    Post subject: Reply with quote

though this line shows up in many places and would take a long time to go through them all. the file src/httpd-2.0.55/modules/http/http_protocol.c in the source did have this...
Code:
/* Output the HTTP/1.x Status-Line and the Date and Server fields */


Now, i am not a C programmer, but poking around at the code leads me to believe it should either be sending a 1.0 or a 1.1 code, i can't figure out where 1.x comes from.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 18 May '07 19:48    Post subject: Reply with quote

Yes - Apache only has "1.x" in comments, like the one you found in http_protocol.c.
The only two "200 OK" responses that Apache can generate are:
    HTTP/1.1 200 OK
    -and-
    HTTP/1.0 200 OK
I meant, does your application have "1.x" in it anywhere? In a .pl script perhaps?
Back to top
iamwyza



Joined: 16 May 2007
Posts: 15

PostPosted: Fri 18 May '07 19:59    Post subject: Reply with quote

I don't think so, i grepped all the code. Also every image, css, ect. are all served with http/1.x as well. The get statement uses 1.1 but the response is 1.x.
Back to top


Reply to topic   Topic: Odd Header Behavior View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page 1, 2  Next