Mark Williams 14 Posted August 18, 2019 This is in connection with the AddHeader function of the IHTTPRequest. I'm trying to add a multiline text which also contains numerous characters such as = signs etc. I am getting the above error as a result. Is it even possible to do this? Should I be formatting the text in some way before adding it? UrlEncode? Share this post Link to post
Guest Posted August 18, 2019 https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.1 Share this post Link to post
Mark Williams 14 Posted August 19, 2019 Hi Thanks, As far as I can see (and with my limited understanding of the protocols) it is compliant with the requirements for headers. Each line break is coded +Chr(32)+sLineBreak; There are no line breaks inserted other than in this manner, but I still get the error. Does anyone know of any function for encoding text in away that will satisfy the protocol? Share this post Link to post
Guest Posted August 19, 2019 Why do you need to send "multiline" text in the header? It sounds like food for the payload. Anyway, my interpretation of the link above is that each key-value pair in the headers should NOT contain CRLF. So Base64 encoding would be my first labrat. Share this post Link to post
Mark Williams 14 Posted August 19, 2019 5 hours ago, Dany Marmur said: Why do you need to send "multiline" text in the header? It sounds like food for the payload. Anyway, my interpretation of the link above is that each key-value pair in the headers should NOT contain CRLF. So Base64 encoding would be my first labrat. I tried Base64. This may have worked, but I think I'm running into a limitation as to permissible size of header. I absolutely agree that it is food for the payload, but I have tried and failed to submit/receive content using THTTPClient and TWebRequest components. My code for submitting the component is below, but when I try and access the TWebRequest's content it remains stubbornly empty. FHttpClient:=THttpClient.Create; try With FHttpClient do begin data:=TStringStream.Create; try data.WriteString(content); ContentType:='text/html'; Accept:='text/plain, */*'; AcceptCharSet:='utf-8'; LResponse:=FHttpClient.Post(Script, data); finally data.Free; end; end; I have now resorted to submitting it as multipartdata, which works, but seems overkill just to submit a string. Share this post Link to post
Guest Posted August 19, 2019 6 hours ago, Mark Williams said: I have now resorted to submitting it as multipartdata, which works, but seems overkill just to submit a string. Hmmm... that sound like a cry from the 80's. Noooo... daily millions, billions and billions of requests and responses are distributed. IMHO your intention is called "premature optimisation". Multipart works fine. If you are at the stage where you can do some real-world sims and tests, do. I would even bet moneys that you will not much performance difference. But the only way to know is to measure. 1; stability, extendability, maintainability, security, and so on and so forth. 2: perform better that the competition (say) they do. The comparison will judge between apples and peaches anyway. 6 hours ago, Mark Williams said: but I have tried and failed to submit/receive content using THTTPClient and TWebRequest I do not use these myself. Sorry. But do you write both server and client? Or do you have more to consider? Please provide some more information about you goals and prerequisites and i'm sure you will receive good advice from the gurus. Share this post Link to post
Mark Williams 14 Posted August 22, 2019 Thanks. I do write both server and client. I have it working with multiformdata at moment and am going to leave it at that for now as this is a fairly minor part of a hefty development and I have managed to get myself bogged down in it. I will revisit it when I have a bit more time and do some research online. But thanks for all your help. Share this post Link to post
Guest Posted August 22, 2019 4 hours ago, Mark Williams said: But thanks for all your help. You are MOST welcome! Generally in this forum, you can also credit people by clicking on the heart of the post that helped you and select an appropriate "social media icon" (or whatever ther are called these days". Share this post Link to post