0

I am working in a language that has extremely low-level TCP support (if you must know, it's UnrealScript). The response received after making a POST request includes the entire HTTP header, status code, body, etc. as a string.

So, I need to parse the response to extract the body text manually. The HTTP 1.1 specification says:

Response = Status-Line
           *(( general-header
             | response-header
             | entity-header ) CRLF)
           CRLF
           [message-body]

Am I correct in assuming that the best way to do this is to split the string along a double CRLF (carriage return/line feed) and return the second part of this split?

Or are there weird HTTP edge cases I should be aware of?

1 Answer 1

1

Am I correct in assuming that the best way to do this is to split the string along a double CRLF

Yes - but what appears in the body may be compressed using three different compressions methods even if you told the server you don't accept compressed responses.

Further the body may be split into chunks, in between each chunk is an indicator of the size of the next chunk.

Do you really have no scope for using an off the shelf component for parsing? (I would recommend lib curl).

Sign up to request clarification or add additional context in comments.

1 Comment

Sounds fun...yeah I'm aware of the chunking part as well, but right now my biggest problem is simply stripping the header. And unfortunately the code must be as "native" as possible, I could DLL-bind to an outside library but it brings up a whole bunch of other problems. Thanks for your answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.