Enhance Gitea support and ensure UTF-8 encoding in API requests
This commit is contained in:
@@ -87,17 +87,24 @@ function oribi_sync_api_request( string $method, string $url, array $body, strin
|
||||
$headers = array_merge(
|
||||
oribi_sync_auth_headers( $provider, $pat ),
|
||||
[
|
||||
'Content-Type' => 'application/json',
|
||||
'Content-Type' => 'application/json; charset=utf-8',
|
||||
'Accept' => 'application/json',
|
||||
'User-Agent' => 'Oribi-Sync-WP/' . ORIBI_SYNC_VERSION,
|
||||
]
|
||||
);
|
||||
|
||||
// Ensure UTF-8 encoding of all body content
|
||||
array_walk_recursive( $body, function ( &$item ) {
|
||||
if ( is_string( $item ) && ! mb_check_encoding( $item, 'UTF-8' ) ) {
|
||||
$item = mb_convert_encoding( $item, 'UTF-8' );
|
||||
}
|
||||
});
|
||||
|
||||
$args = [
|
||||
'method' => $method,
|
||||
'timeout' => 30,
|
||||
'headers' => $headers,
|
||||
'body' => wp_json_encode( $body ),
|
||||
'body' => wp_json_encode( $body, JSON_UNESCAPED_UNICODE ),
|
||||
];
|
||||
|
||||
$response = wp_remote_request( $url, $args );
|
||||
|
||||
Reference in New Issue
Block a user