|
3 | 3 |
|
4 | 4 | The `http` Fortran package provides a **simple and convenient** way to make HTTP requests and retrieve responses. It aims to **simplify** the process of interacting with web services by providing a high-level API.
|
5 | 5 |
|
6 |
| -Currently package includes the following features: |
| 6 | +___ |
| 7 | +## **Features** |
7 | 8 |
|
8 |
| -* Sending `GET` request (`POST`, `PUT`, `DELETE`, and other HTTP requests coming soon). |
9 |
| -* Handling response data, including status code, content length, method, headers and content. |
10 |
| -* Support for custom headers and request parameters. |
11 |
| -* Error handling for unsuccessful requests. |
| 9 | + The package includes the following features: |
| 10 | + |
| 11 | + 1. #### **Sending HTTP Requests:** |
| 12 | + - **`GET`**: Retrieve data from the server. |
| 13 | + - **`POST`**: Submit data to be processed by the server. |
| 14 | + - **`PUT`**: Replace or create resources on the server. |
| 15 | + - **`DELETE`**: Remove resources from the server. |
| 16 | + - **`PATCH`**: Partial updates to resources. |
| 17 | + - **`HEAD`**: Retrieve response headers without the response content. |
| 18 | + |
| 19 | + 2. #### **Data Support:** |
| 20 | + - Send any type of data with requests, including support for `file` uploads and `form data`. |
| 21 | + |
| 22 | + 3. #### **Response Handling:** |
| 23 | + - Retrieve response `content`. |
| 24 | + - Get the HTTP `status code` returned by the server. |
| 25 | + - Fetch the `length` of the response content. |
| 26 | + - Access response `headers`. |
| 27 | + |
| 28 | + 4. #### **Custom Headers:** |
| 29 | + - Include `custom headers` in requests to the server. |
| 30 | + |
| 31 | + 5. #### **Error Handling:** |
| 32 | + - Detect and handle unsuccessful requests gracefully, with informative `error messages`. |
| 33 | + |
| 34 | + 6. #### **Request Timeout:** |
| 35 | + - Set a maximum time allowed for a request to complete, improving responsiveness. |
| 36 | + |
| 37 | + 7. #### **Authentication:** |
| 38 | + - Authenticate requests to protected resources using standard authentication methods. |
| 39 | + |
| 40 | +## **Installation** |
| 41 | + |
| 42 | + Before building the `http-client` library, ensure that you have the necessary dependencies installed. On Ubuntu, you need to install the curl development headers. Use the following command: |
12 | 43 |
|
13 |
| -## **Prerequisites** |
14 |
| -Before building the library, ensure that you have the necessary dependencies installed. On `Ubuntu`, you need to install the curl development headers. Use the following command: |
15 | 44 | ```
|
16 | 45 | sudo apt install -y libcurl4-openssl-dev
|
17 | 46 | ```
|
18 |
| -## **fpm usage** |
19 |
| -To use `http` within your fpm project, add the following to your package manifest file (fpm.toml): |
| 47 | + |
| 48 | + To use `http-client` within your fpm project, add the following to your package `fpm.toml` file: |
| 49 | + |
20 | 50 | ```toml
|
21 | 51 | [dependencies]
|
22 |
| -fhash = { git = "https://github.com/fortran-lang/http-client.git" } |
| 52 | +http = { git = "https://github.com/fortran-lang/http-client.git" } |
| 53 | +stdlib = "*" |
23 | 54 | ```
|
24 | 55 | ## **Usage Example**
|
25 | 56 | The following example demonstrates how to use the http package to make a **Simple GET request** and process the response
|
@@ -61,6 +92,40 @@ end program simple_get
|
61 | 92 | ```
|
62 | 93 | In this example, we make a GET request to the URL https://jsonplaceholder.typicode.com/todos/1 to retrieve JSON data. If the request is successful, we print the ***response code, content length, method, and content***. If the request fails, we print the ***error message***.
|
63 | 94 |
|
| 95 | +## **Getting Started Guides** |
| 96 | +> ### ***The Complete Tutorial Guide is <u> Currently in progress</u> and will be available soon.*** |
| 97 | +1. ### **Installation** 👋 |
| 98 | + - Installing Dependencies (Ubuntu) |
| 99 | + - Setting up the Package in your Project |
| 100 | + |
| 101 | +2. ### **Making HTTP Requests** 🚀 |
| 102 | + - **Sending `GET` Requests** |
| 103 | + - *Accessing Response `Content`* |
| 104 | + - *Retrieving `Status Codes`* |
| 105 | + - *Getting Response `Headers`* |
| 106 | + - *Extracting `Content Length`* |
| 107 | + - **Sending `POST` Requests** |
| 108 | + - *Sending `Data` with Requests* |
| 109 | + - *Sending `Form Data`* |
| 110 | + - *Uploading `File`* |
| 111 | + - **Sending `PUT` Requests** |
| 112 | + - **Sending `PATCH` Requests** |
| 113 | + - **Sending `DELETE` Requests** |
| 114 | + - **Sending `HEAD` Requests** |
| 115 | + |
| 116 | +3. ### **Customizing Requests** ✏️ |
| 117 | + - Sending Custom **Headers** |
| 118 | + - Setting Request **Timeout** |
| 119 | + - **Authentication** Option |
| 120 | + |
| 121 | +4. ### **Error Handling** 🤨 |
| 122 | + - Handling Unsuccessful Requests |
| 123 | + - Displaying Error Messages |
| 124 | + |
| 125 | +5. ### **Real Projects** 🤖 |
| 126 | + - **GitHub organization analyzer** : Retrieve valuable information about the organization repositories |
| 127 | + |
| 128 | + |
64 | 129 | ## **Contributing to project**
|
65 | 130 | Thank you for your interest in contributing to the `http` Fortran package! Contributions from the community are valuable in improving and enhancing the functionality of the package. This section provides a guide on how to get the code, build the library, and run examples and tests.
|
66 | 131 |
|
@@ -99,7 +164,19 @@ fpm test
|
99 | 164 | ```
|
100 | 165 | Running the tests will validate the behavior of the package and help identify any issues or regressions.
|
101 | 166 |
|
102 |
| -### Supported compilers |
| 167 | +### **Generating API Documentation** |
| 168 | + |
| 169 | +Before generating API documentation, ensure that you have FORD installed on your system. |
| 170 | + |
| 171 | +**Installation link**: [https://github.com/Fortran-FOSS-Programmers/ford#installation](https://github.com/Fortran-FOSS-Programmers/ford#installation) |
| 172 | + |
| 173 | +Once FORD is set up, execute the following command to build the API documentation: |
| 174 | + |
| 175 | +```bash |
| 176 | +ford ford.md |
| 177 | +``` |
| 178 | + |
| 179 | +### **Supported compilers** |
103 | 180 |
|
104 | 181 | http-client is known to work with the following compilers:
|
105 | 182 |
|
|
0 commit comments