Closed rajkumardongre closed 1 year ago
I recommend not to couple your architecture to closely with cURL. Ideally, you just call cURL in a single function or subroutine that translates your types to cURL. Your data structures should follow the HTTP protocol, not the public API of cURL. You don’t even need to store cURL pointers (curl_ptr
, header_list_ptr
) in your derived types, since they will be NULL
once the request has been finished. This way, we are technically able to replace the backend in future (for instance, libsoup instead of cURL).
Thanks, @interkosmos for your suggestion, If I understand correctly, you are suggesting that we should perform all cURL related tasks in a single function or subroutine, which in our case would be client_get_response()
within the http_client.f90 file. Additionally, you propose removing curl_ptr
and header_list_ptr
from the client_type
and header_type
derived types. Is my understanding correct? Please let me know if I have misunderstood your suggestion.
Yes, you are correct. But see it as a proposal we can discuss.
Alright, in the meantime, I will work on updating the API as per your recommendation in a separate branch.
Hello @interkosmos, I have implemented the necessary modifications in my latest pull request. I would appreciate it if you could review it.
Done by #21.
Hello, I have come up with an idea for passing headers to an HTTP request. My idea involves creating a derived type named
header_type
, below is it's defination :since curl maintains a linked list for storing the request header,
header_list_ptr
will point to the head of the linked list,header_count
will maintain the total number of headers passed to the request.set_header
subroutine will take the headerkey
andvalue
as input argument and store it inside the header linked list in the required format.Here is an example of how this approach can be used to add headers to an HTTP request:
I have added an example of this approach in my recent commit for further insight. I would appreciate your thoughts and suggestions on this approach.