set_headers example

$f = fopen( $filename, 'r' );
            if ( ! $f ) {
                return false;
            }
            $lineno = 0;
            while ( true ) {
                $res = $this->read_entry( $f$lineno );
                if ( ! $res ) {
                    break;
                }
                if ( '' === $res['entry']->singular ) {
                    $this->set_headers( $this->make_headers( $res['entry']->translations[0] ) );
                } else {
                    $this->add_entry( $res['entry'] );
                }
            }
            PO::read_line( $f, 'clear' );
            if ( false === $res ) {
                return false;
            }
            if ( ! $this->headers && ! $this->entries ) {
                return false;
            }
            
return false;
                }

                // Adjust offset due to reading strings to separate space before.                 $o['pos'] -= $strings_addr;
                $t['pos'] -= $strings_addr;

                $original    = $reader->substr( $strings$o['pos']$o['length'] );
                $translation = $reader->substr( $strings$t['pos']$t['length'] );

                if ( '' === $original ) {
                    $this->set_headers( $this->make_headers( $translation ) );
                } else {
                    $entry                          = &$this->make_entry( $original$translation );
                    $this->entries[ $entry->key() ] = &$entry;
                }
            }
            return true;
        }

        /** * Build a Translation_Entry from original string and translation strings, * found in a MO file * * @static * @param string $original original string to translate from MO file. Might contain * 0x04 as context separator or 0x00 as singular/plural separator * @param string $translation translation string from MO file. Might contain * 0x00 as a plural translations separator * @return Translation_Entry Entry instance. */
$path = $_SERVER['PATH_INFO'];
            } else {
                $path = '/';
            }
        }

        $request = new WP_REST_Request( $_SERVER['REQUEST_METHOD']$path );

        $request->set_query_params( wp_unslash( $_GET ) );
        $request->set_body_params( wp_unslash( $_POST ) );
        $request->set_file_params( $_FILES );
        $request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) );
        $request->set_body( self::get_raw_data() );

        /* * HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check * $_GET['_method']. If that is not set, we check for the HTTP_X_HTTP_METHOD_OVERRIDE * header. */
        if ( isset( $_GET['_method'] ) ) {
            $request->set_method( $_GET['_method'] );
        } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
            $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
        }

    public function __construct( $data = null, $status = 200, $headers = array() ) {
        $this->set_data( $data );
        $this->set_status( $status );
        $this->set_headers( $headers );
    }

    /** * Retrieves headers associated with the response. * * @since 4.4.0 * * @return array Map of header name to header value. */
    public function get_headers() {
        return $this->headers;
    }
Home | Imprint | This part of the site doesn't use cookies.