I am running a simple client code in C to do POST and GET to server and read data stream. Currently I am printing full response received in recv()
and have to parse it for further use. Before reading data stream, I want to know what is HTTP status code (200, 400, 401 etc.) from server. I am getting same in Header. Is there a way to get HTTP code before reading Headers?
What is best practice to Read Head parameters and Payload? I searched but answers I got are to read '\r\n' sequence and than apply logic. Is there any better way?
I am using Ubuntu systems for testing this code. Following is response being printed:
<p style="color:blue;">HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Content-Type: application/json
Content-Length: 69
Date: Mon, 08 Aug 2016 09:46:46 GMT
</p>
<p style="color:blue;">"You are not a authorized user to access this resource. Access denied."