Wednesday, June 10, 2009

Extra CRLF in the POST request

Some times Servers may receive POST request with an extra CRLF ,which mostly added by clients(browsers) . Because some servers (e.g CERN webserver) require this extra CRLF to process. As per the RFC this is not a valid request , for this reason only ,content length header in the POST request will not include this CRLF.

generic-message = start-line
*(message-header CRLF)
[ message-body ]
start-line = Request-Line | Status-Line

This is the BNF for the http requests. In this after each header there should be one CRLF to indicate the end of the header , and one extra CRLF should be between the headers and the body to differentiate message body with headers. In message-body there should not be any CRLF's.

Certain buggy HTTP/1.0 client implementations generate extra CRLF's after a POST request. To restate what is explicitly forbidden by the BNF, an HTTP/1.1 client MUST NOT preface or follow a request with an extra CRLF.

Tuesday, June 9, 2009

Printing whole string in GDB

In GDB generally to print the value of the variable ,we use print or just p .
But for the strings or arrays of large size , it wont print whole string or array.
we have to do some modifications.

By default GDB will print upto 200 characters ,if the string is very large.
To change this there is command in GDB

set print elements number-of-elements

Set a limit on how many elements of an array GDB will print. If GDB is printing a large array, it stops printing after it has printed the number of elements set by the set print elements command. This limit also applies to the display of strings. Setting number-of-elements to zero means that the printing is unlimited.

(gdb) set print element 20

next time it will print upto 20 characters

(gdb) set print element 50

next time it will print upto 20 characters

(gdb) set print element 0

next time it will print whole array or string

Popular Posts