@@ -188,14 +188,14 @@ namespace jdl {
188188
189189 struct HTTPClient {
190190 typedef enum {
191- OPTIONS = 0 ,
192- GET ,
193- HEAD ,
194- POST ,
195- PUT ,
196- DELETE ,
197- TRACE ,
198- CONNECT
191+ m_options = 0 ,
192+ m_get ,
193+ m_head ,
194+ m_post ,
195+ m_put ,
196+ m_delete ,
197+ m_trace ,
198+ m_connect
199199 } HTTPMethod;
200200
201201 inline static const char *method2string (HTTPMethod method) {
@@ -204,7 +204,7 @@ namespace jdl {
204204 return methods[method];
205205 }
206206
207- inline static int connectToURI (const URI& uri) {
207+ inline static socktype_t connectToURI (const URI& uri) {
208208 struct addrinfo hints, *result, *rp;
209209
210210 memset (&hints, 0 , sizeof (addrinfo));
@@ -228,7 +228,7 @@ namespace jdl {
228228 continue ;
229229 }
230230
231- int connect_result = connect (fd, rp->ai_addr , rp->ai_addrlen );
231+ int connect_result = connect (fd, rp->ai_addr , static_cast < socklen_t >( rp->ai_addrlen ) );
232232
233233 if (connect_result == -1 ) {
234234 // successfully created a socket, but connection failed. close it!
@@ -245,16 +245,16 @@ namespace jdl {
245245 return fd;
246246 }
247247
248- inline static std::string bufferedRead (int fd) {
248+ inline static std::string bufferedRead (socktype_t fd) {
249249 size_t initial_factor = 4 , buffer_increment_size = 8192 , buffer_size = 0 ,
250250 bytes_read = 0 ;
251251 std::string buffer;
252252
253253 buffer.resize (initial_factor * buffer_increment_size);
254254
255255 // do {
256- bytes_read = recv (fd, ((char *)buffer.c_str ()) + buffer_size,
257- buffer.size () - buffer_size, 0 );
256+ bytes_read = recv (fd, ((char *)buffer.c_str ()) + buffer_size,
257+ static_cast < socklen_t >( buffer.size () - buffer_size) , 0 );
258258
259259 buffer_size += bytes_read;
260260
@@ -274,7 +274,7 @@ namespace jdl {
274274
275275 inline static HTTPResponse request (HTTPMethod method, const URI& uri, const std::string& body = " " ) {
276276
277- int fd = connectToURI (uri);
277+ socktype_t fd = connectToURI (uri);
278278 if (fd < 0 )
279279 return HTTPResponse::fail ();
280280
@@ -293,11 +293,11 @@ namespace jdl {
293293 " Content-Length: " + std::to_string (body.size ()) + HTTP_NEWLINE + HTTP_NEWLINE +
294294 body;
295295
296- /* int bytes_written = */ send (fd, request.c_str (), request.size (), 0 );
296+ /* int bytes_written = */ send (fd, request.c_str (), static_cast < socklen_t >( request.size () ), 0 );
297297
298298 std::string buffer = bufferedRead (fd);
299299
300- close (fd);
300+ closesocket (fd);
301301
302302 HTTPResponse result;
303303
0 commit comments