You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add Complete Tutorials
* Rename the tutorial file and Update the loop to iterate through all repositories.
* Update the version of fortran-curl
* removed TOC from README.md
* Clean up README
---------
Co-authored-by: milancurcic <[email protected]>
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
-
6
-
___
7
-
## **Features**
8
-
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:
1
+
# http-client
2
+
3
+
http-client is Fortran library to make HTTP requests.
4
+
It simplifies interacting with web services by providing a high-level and
5
+
user-friendly interface.
6
+
7
+
## Features
8
+
9
+
* HTTP request methods:
10
+
-`GET`: Retrieve data from the server.
11
+
-`POST`: Create new data the server.
12
+
-`PUT`: Replace an existing resource on the server.
13
+
-`DELETE`: Delete a resource from the server.
14
+
-`PATCH`: Partially update a resource on the server.
15
+
-`HEAD`: Get response headers without the response content.
16
+
* Supported data types:
17
+
- URL encoded fields
18
+
- HTTP form data
19
+
- File uploads
20
+
* Response handling:
21
+
- Retrieve response body (content).
22
+
- Get the HTTP status code returned by the server.
23
+
- Access response headers.
24
+
* Setting custom request headers
25
+
* Error handling with informative error messages
26
+
* Setting request timeouts
27
+
* Basic HTTP authentication
28
+
29
+
## Installation
30
+
31
+
Before building the http-client library, ensure that you have the necessary
32
+
dependencies installed. On Ubuntu, you need to install the curl development
33
+
headers. Use the following command:
43
34
44
35
```
45
36
sudo apt install -y libcurl4-openssl-dev
46
37
```
47
38
48
-
To use `http-client` within your fpm project, add the following to your package `fpm.toml` file:
39
+
To use http-client as a dependency in your fpm project, add the following to
The following example demonstrates how to use the http package to make a **Simple GET request** and process the response
47
+
48
+
## Example use
49
+
50
+
The following example demonstrates how to use http-client to make a simple `GET`
51
+
request and process the response:
57
52
58
53
```fortran
59
54
program simple_get
@@ -78,7 +73,9 @@ program simple_get
78
73
end program simple_get
79
74
80
75
```
81
-
### Ouptut :
76
+
77
+
Ouptut:
78
+
82
79
```
83
80
Response Code : 200
84
81
Response Length : 83
@@ -90,100 +87,114 @@ end program simple_get
90
87
"completed": false
91
88
}
92
89
```
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***.
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
-
129
-
## **Contributing to project**
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.
131
-
132
-
### **Get the code**
90
+
91
+
In this example, we make a `GET` request to the URL
92
+
https://jsonplaceholder.typicode.com/todos/1 to retrieve JSON data.
93
+
If the request is successful, we print the response code, content length,
94
+
method, and content. If the request fails, we print the error message.
95
+
96
+
## Getting Started Guides
97
+
98
+
To begin your journey with our package, dive into the comprehensive tutorial
99
+
available here: [tutorial.md](./tutorial/tutorial.md)**.
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:
133
+
134
+
### Prerequisites
135
+
136
+
Before building the library, ensure that you have the necessary dependencies
137
+
installed. On Ubuntu, you need to install the curl development headers.
138
+
Use the following command:
139
+
142
140
```
143
141
sudo apt install -y libcurl4-openssl-dev
144
142
```
145
-
### **Build the library**
146
143
147
-
The `http` package uses **fpm** as the build system. Make sure you have fpm `version 0.8.x` or later installed. To build the library, execute the following command within the project directory:
144
+
### Build the library
145
+
146
+
http-client uses **fpm** as the build system. Make sure you have fpm-0.8.x or
147
+
later installed. To build the library, run the following command within the
148
+
project directory:
149
+
148
150
149
151
```
150
152
fpm build
151
153
```
152
-
### **Run examples**
153
-
The http package provides example programs that demonstrate its usage. To run the examples, use the following command:
154
+
155
+
### Run examples
156
+
157
+
http-client provides example programs that demonstrate its use. To run the
158
+
examples, use the following command:
154
159
155
160
```
156
161
fpm run --example <example name>
157
162
```
158
-
Executing this command will execute the example programs, allowing you to see the package in action and understand how to utilize its features.
159
163
160
-
### **Run tests**
161
-
The http package includes a test suite to ensure its functionality is working as expected. To run the tests, execute the following command:
164
+
Executing this command will execute the example programs, allowing you to see
165
+
the package in action and understand how to utilize its features.
166
+
167
+
### Run tests
168
+
169
+
http-client includes a test suite to ensure its functionality is working as
170
+
expected. To run the tests, type:
171
+
162
172
```
163
173
fpm test
164
174
```
165
-
Running the tests will validate the behavior of the package and help identify any issues or regressions.
166
175
167
-
### **Generating API Documentation**
176
+
Running the tests will validate the behavior of the package and help identify
177
+
any issues or regressions.
168
178
169
-
Before generating API documentation, ensure that you have FORD installed on your system.
0 commit comments