Reputation: 134
I'm using python and the socket library to see exactly what I'm sending.
I know that each line must end with a CRLF. I also know that the length of the body must be sent in the headers (with Content-Length).
What I don't know, is if I must send my body like a string ended with a CRLF, or like several strings, each ended with a CRLF. And, in the last case, must I include the CRLF in the length of my body ?
Upvotes: 0
Views: 477
Reputation: 199
Your XML shouldn't have any CRLFs.
xmlData = "<?xml version=\"1.0\"?> <d:propfind xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\"> <d:prop> <d:displayname /> <d:getetag /> </d:prop> </d:propfind>";
There is no need to encode it. Just include "Content-Length:" and "Content-Type:" in the header. You must separate headers with the body using CRLF. But, in Content-Length:, you don't have to consider CRLF (unless you are sending them).
Upvotes: 0
Reputation: 309008
The length of the body should include all characters, including CR and LF.
If you're sending XML, I don't agree that each line must end with a CRLF. Sending pretty printed XML is unnecessary. (That's for humans; only machines are involved in this transaction.) I'd remove all of those and send it as one long string.
It's very important that you encode it properly if you're using HTTP as your protocol.
I'd wonder why if you're using raw sockets instead of HTTP. XML over HTTP is well understood.
Upvotes: 1