Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code quality improvements #226

Merged
merged 21 commits into from
Nov 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure that no cache control headers are sent when using oauth1
jonnynews committed Nov 23, 2023
commit d270e2a254730bc75bdf44d76223bb942b5ea774
4 changes: 3 additions & 1 deletion oauth-server.php
Original file line number Diff line number Diff line change
@@ -128,6 +128,9 @@ function rest_oauth1_loaded() {
$authenticator = new WP_REST_OAuth1();
$response = $authenticator->dispatch( $GLOBALS['wp']->query_vars['rest_oauth1'] );

nocache_headers();
header( 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' );

if ( is_wp_error( $response ) ) {
$error_data = $response->get_error_data();
if ( is_array( $error_data ) && isset( $error_data['status'] ) ) {
@@ -141,7 +144,6 @@ function rest_oauth1_loaded() {
die();
}

header( 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' );
$response = http_build_query( $response, '', '&' );

echo $response;