[fpc-pascal] Improvement to TFPHTTPClient Class

Michael Van Canneyt michael at freepascal.org
Wed Jul 20 08:45:42 CEST 2016



On Tue, 19 Jul 2016, African Wild Dog wrote:

> 2016-07-19 4:52 GMT-03:00 Michael Van Canneyt <michael at freepascal.org>:
>
>>
>> 1. The whole point of TFPHTTPClient is exactly to couple it to sockets
>>    framework (fcl-net).
>>    If you want to use synapse, use httpsend. lnet has a similar component
>>    for the http protocol.
>>
>>
> I dont want to use synapse. I am developing bindings for a c library. The
> library offers TCP connection functionality but does not provide any
> support for http. I need to use that library due to some particularities of
> my project.
>
> I do not understand the need for such coupling between http client and
> fcl-net. It is like coupling SQLDb with a specific RDBMS.

The comparison is at fault, but I will not press the point.

>> 2. I favour the opposite approach. Abstract out the underlying HTTP
>> implementation
>>    at a higher level.
>>
>
> Why should we duplicate the code? Why should we implement the same
> functionality in several diferent places?

Because all Pascal TCP toolkits out there offer a HTTP Client. (lnet, indy,
synapse). By doing this, I leave the choice up to the user which one to use
for various APIs that are built ON TOP of HTTP.

Your use case is simply one I didn't foresee,
Because I assume that any decent TCP toolkit offers a HTTP client.

However, now that I understand what you actually need, we can consider this use-case.

I will accept the patch, on the condition that you provide a binding for a C
TCP/IP library too. If your c library is open source, then we can use that.
if not, then I'd ask you to provide an libevent implementation.

It has no point abstracting out something if we have only 1 implementation.

Michael.



More information about the fpc-pascal mailing list