Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dealing with binaries and text in TIdHTTP
#3
It should be possible to do both binary and text based requests, as transparently as possible. I'm aiming for a small interface, decoupled from Indy, to keep my code isolated from third party components and have easier mocking/stubbing.

Text may be sent in an appropriate encoding decided by Indy (assuming it will indicate that encoding in the headers). The main thing here is that Indy must know if the Body contains actual text or just bytes, preferably without having to set that as a separate flag. Maybe setting the right ContentType will do, or making Body a RawByteString will make it so that assigning a regular String will mark it as text whereas BytesOf won't...?

When receiving the response, I'd like Indy to decode text but leave binary as is, based on the content type and encoding specified by the server. So, if possible, I would prefer the caller not having to indicate whether they are expecting text or binary. It's acceptable if the caller still needs to expect the response to decide whether to interpret the Body as text or binary, but in case of text they should not be required to decode it themselves. Again, preferably without a flag, but even if there would be a flag, I don't know based on what I could set it in the Perform method, i.e. if Indy can tell me whether it's likely text or binary that was received.

I hope this makes some sense.
Reply


Messages In This Thread
RE: Dealing with binaries and text in TIdHTTP - by thijsvandien - 12-17-2018, 07:05 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)