fortran-lang / http-client

http-client offers a user-friendly, high-level API to make HTTP requests in Fortran.
https://http-client.fortran-lang.org/
MIT License
60 stars 8 forks source link

Add functionality for sending files via HTTP POST requests. #33

Closed rajkumardongre closed 1 year ago

rajkumardongre commented 1 year ago

I have done some changes in set_body function to send files also :

The set_body function determines the type of data to include in the request body based on the inputs provided. If data is provided, it is sent as the body of the request. If form is provided without a file, the form data is URL encoded and sent as the body of the request. If file is provided without form, the file is sent using a multipart/form-data header. If both form and file are provided, the file takes priority and the form along with file is sent as part of the multipart/form-data body. If data, form, and file are all provided, only data is sent and the form and file inputs are ignored.

rajkumardongre commented 1 year ago

Since file_type(in http_file.f90 file), form_type(in http_form.f90 file), and header_type(in http_header.f90 file) derived types have an almost similar definition, i.e they are used to store 2 character string, so can we replace all these derived types with a single derived type.

here is my suggested derived type, which we can use instead of file_type, form_type, and header_type:

type :: pair_type
    character(:), allocatable :: name
    character(:), allocatable :: value
end type pair_type

I think using this approach our library will become more user-friendly as the user doesn't have to remember so many derived types.

milancurcic commented 1 year ago

@rajkumardongre, I agree, let's go with the pair_type for all these use cases.

milancurcic commented 1 year ago

Closing in favor of #34