Hi.
I`m working on a socket server written in c, where I have to read (and parse) the header informations sent by a browser. The problem is that because of the possible POST and GET variables I don`t know exactly how long the header string will be so I can`t declare the read buffer statically (for ex. char buf[512]). I thought about two possibilities:
1. read the bytes from the socket one by one, and reallocate the space for the buffer each time.
2. allocate say 128 or 256 bytes for the buffer from the start, and increase it if necessary.
What do you think, what would be the best way to do this? Any suggestion is welcome.
Thank you.