# jetformbuilder/3.6.6/components/rest-api/rest-response.php

JetFormBuilder — Dynamic Blocks Form Builder, version 3.6.6. 36 lines.

- Page: https://pluginprobe.com/plugins/jetformbuilder/3.6.6/code/components/rest-api/rest-response.php
- Raw: https://pluginprobe.com/plugins/jetformbuilder/3.6.6/raw/components/rest-api/rest-response.php
- Modified: 2023-11-20T11:46:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetformbuilder/3.6.6/code/components/rest-api/rest-response.php#L10-L20`.

```php
<?php


namespace JFB_Components\Rest_Api;

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

class Rest_Response extends \WP_REST_Response {

	public function get_custom_header_prefix(): string {
		return 'X-JFB-';
	}

	public function set_headers_merge( array $headers ) {
		if ( ! is_array( $this->headers ) ) {
			$this->set_headers( array() );
		}

		$this->set_headers( array_merge( $this->headers, $headers ) );
	}

	public function set_headers_custom( $headers ) {
		$prefix   = $this->get_custom_header_prefix();
		$prepared = array();

		foreach ( $headers as $name => $value ) {
			$prepared[ $prefix . $name ] = $value;
		}

		$this->set_headers_merge( $prepared );
	}
}

```
