-
Notifications
You must be signed in to change notification settings - Fork 8
Add fortran-curl as dependency and a minimal GET request example #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few remarks:
- The
method
attribute inrequest_type
andresponse_type
should probably be of typeinteger
. - The
status_code
inresponse_type
has no default value. HTTP status codes should be added as public parameters. The attributecontent_length
should be an 8-byte integer, as it is available in Fortran on 32-bit platforms too. - Some procedure dummy arguments still need proper
intent
attributes. - In
new_request()
,switch case
is preferable toif … then … else
blocks. - The function
client_get_response
should not stop on error but return an error code/message instead.
Alright, I'll make the required changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @rajkumardongre. I suggest also organizing defining the derived types and their related procedures in their respective modules, and use http_client
module only to make available the public API, i.e. response_type
, http_request
, HTTP_GET
etc.
src/http-client.f90
Outdated
character(len=*) :: url | ||
integer, optional :: method | ||
type(request_type) :: request | ||
type(response_type) :: response | ||
type(client_type) :: client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one space around ::
, no need for all this whitespace.
src/http-client.f90
Outdated
rc = curl_easy_setopt(curl_ptr, CURLOPT_URL, this%request%url // c_null_char) | ||
! setting request method | ||
rc = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, this%request%method // c_null_char) | ||
! setting callback for writing received data | ||
rc = curl_easy_setopt(curl_ptr, CURLOPT_WRITEFUNCTION, c_funloc(client_response_callback)) | ||
! setting response pointer to write callback | ||
rc = curl_easy_setopt(curl_ptr, CURLOPT_WRITEDATA, c_loc(response)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well, and elsewhere, just one space after commas.
Thanks, @milancurcic. So basically, I need to generate four files.
|
Yeah, Looks good. But maybe use snake_case for naming |
@rajkumardongre check the recent fpm module and source naming requirements: https://fpm.fortran-lang.org/en/spec/naming.html Because the default
(and having the Another thing we should decide early is whether to use the old and inappropriate .f90 for source suffixes, or to just go with .f (now that free form is assumed, https://fpm.fortran-lang.org/en/spec/manifest.html#source-form). Since we just started, this project may be a perfect guinea pig to find out if there are any unforeseen issues with using So, my suggestion for this PR is to have these source files: Let me know what you all think. |
Thank you, @milancurcic. I believe using a custom prefix would be a good approach, but I do have a concern. Our package name is |
I see, good point. In that case, should we rename our package to just |
Yes, I also think So now we can follow this structure :
|
OK, let's go ahead then and rename it in pyproject.toml and I'll rename the repo after we merge the PR. |
It just occurred to me that this PR is also on a branch on fortran-lang/http-client rather than your fork (rajkumar/http-client). Please work only on development branches on your fork going forward. I'll merge this PR as is to not complicate further, and let's tackle the outstanding comments in separate PRs. |
Add fortran-curl as dependency and a minimal GET request example, also added a simple_get.f90 file in example folder