Skip to content

Commit

Permalink
Merge pull request #8 from henrywhitaker3/dev
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
henrywhitaker3 authored Aug 12, 2020
2 parents ea30395 + 0128c9b commit c9dc8be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.1] - 2020-08-12
### Added
- Added custom user-agent to Http requests
12 changes: 11 additions & 1 deletion src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

class HttpClient
{
/**
* User-agent stirng
*
* @var String
*/
static $userAgent = 'PHP-healthchecks.io/1.0';

/**
* Perform a GET request against a specific URL
*
Expand All @@ -18,6 +25,7 @@ public static function get(String $url, array $headers = [])
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_USERAGENT => HttpClient::$userAgent,
CURLOPT_HTTPHEADER => $headers,
];
curl_setopt_array($curl, $curlConfig);
Expand Down Expand Up @@ -49,6 +57,7 @@ public static function post(String $url, array $headers = [], array $data = [])
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_USERAGENT => HttpClient::$userAgent,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data)
];
Expand Down Expand Up @@ -80,6 +89,7 @@ public static function delete(String $url, array $headers = [])
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_USERAGENT => HttpClient::$userAgent,
CURLOPT_CUSTOMREQUEST => 'DELETE'
];
curl_setopt_array($curl, $curlConfig);
Expand All @@ -94,4 +104,4 @@ public static function delete(String $url, array $headers = [])
'status' => $status,
];
}
}
}

0 comments on commit c9dc8be

Please sign in to comment.