Skip to content

Commit

Permalink
Merge pull request #311 from Automattic/update/http-api-constant
Browse files Browse the repository at this point in the history
Use constants for content-type headers
  • Loading branch information
gudmdharalds authored Oct 20, 2022
2 parents 7d1b929 + da05eb5 commit 2f45d64
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
define( 'VIPGOCI_KB_IN_BYTES', 1024 );

/*
* Timeout constant for HTTP APIs.
* Constants for HTTP API functions.
*/
define( 'VIPGOCI_HTTP_API_LONG_TIMEOUT', 20 );
define( 'VIPGOCI_HTTP_API_SHORT_TIMEOUT', 5 );
define( 'VIPGOCI_HTTP_API_CONTENT_TYPE_APPLICATION_JSON', 'application/json' );
define( 'VIPGOCI_HTTP_API_CONTENT_TYPE_X_WWW_FORM_URLENCODED', 'application/x-www-form-urlencoded' );

/*
* Define exit-codes
Expand Down
2 changes: 1 addition & 1 deletion http-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ function vipgoci_http_api_post_url(
bool $http_delete = false,
bool $json_encode = true,
int $http_version = CURL_HTTP_VERSION_NONE,
string $http_content_type = 'application/json'
string $http_content_type = VIPGOCI_HTTP_API_CONTENT_TYPE_APPLICATION_JSON
) :string|int {
/*
* Actually send a request to HTTP API -- make sure
Expand Down
2 changes: 1 addition & 1 deletion wp-core-misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ function vipgoci_wpcore_api_determine_slug_and_other_for_addons(
false, // HTTP POST.
false, // Do not JSON encode.
CURL_HTTP_VERSION_1_1, // Use HTTP version 1.1 due to problems with HTTP 2.
'application/x-www-form-urlencoded' // Custom HTTP Content-Type.
VIPGOCI_HTTP_API_CONTENT_TYPE_X_WWW_FORM_URLENCODED // Use custom HTTP content-type header.
);

if ( is_int( $api_data_raw ) ) {
Expand Down

0 comments on commit 2f45d64

Please sign in to comment.