header_remove example

// As recommended by RFC 8297, PHP automatically copies headers from previous 103 responses, we need to deal with that if headers changed             if (103 === $statusCode) {
                $previousValues = $this->sentHeaders[$name] ?? null;
                if ($previousValues === $values) {
                    // Header already sent in a previous response, it will be automatically copied in this response by PHP                     continue;
                }

                $replace = 0 === strcasecmp($name, 'Content-Type');

                if (null !== $previousValues && array_diff($previousValues$values)) {
                    header_remove($name);
                    $previousValues = null;
                }

                $newValues = null === $previousValues ? $values : array_diff($values$previousValues);
            }

            foreach ($newValues as $value) {
                header($name.': '.$value$replace$this->statusCode);
            }

            if ($informationalResponse) {
                
if (!$this->config->get('cookie_note_mode') || !$this->config->get('show_cookie_note')) {
            return;
        }

        $allowCookie = $this->request->cookies->getInt('allowCookie');

        if ($this->config->get('cookie_note_mode') === CookieRemoveSubscriber::COOKIE_MODE_ALL) {
            if ($allowCookie === 1) {
                return;
            }

            header_remove('Set-Cookie');

            $this->cookieRemoveHandler->removeAllCookies($this->request, $this->response);

            return;
        }

        if ($this->config->get('cookie_note_mode') === CookieRemoveSubscriber::COOKIE_MODE_TECHNICAL) {
            if ($allowCookie === 1) {
                return;
            }

            

function nocache_headers() {
    if ( headers_sent() ) {
        return;
    }

    $headers = wp_get_nocache_headers();

    unset( $headers['Last-Modified'] );

    header_remove( 'Last-Modified' );

    foreach ( $headers as $name => $field_value ) {
        header( "{$name}: {$field_value});
    }
}

/** * Sets the HTTP headers for caching for 10 days with JavaScript content type. * * @since 2.1.0 */
// As recommended by RFC 8297, PHP automatically copies headers from previous 103 responses, we need to deal with that if headers changed             if (103 === $statusCode) {
                $previousValues = $this->sentHeaders[$name] ?? null;
                if ($previousValues === $values) {
                    // Header already sent in a previous response, it will be automatically copied in this response by PHP                     continue;
                }

                $replace = 0 === strcasecmp($name, 'Content-Type');

                if (null !== $previousValues && array_diff($previousValues$values)) {
                    header_remove($name);
                    $previousValues = null;
                }

                $newValues = null === $previousValues ? $values : array_diff($values$previousValues);
            }

            foreach ($newValues  as $value) {
                header($name.': '.$value$replace$this->statusCode);
            }

            if ($informationalResponse) {
                
if (11 !== strpos($h$sessionCookieWithId, 11)) {
                    $otherCookies[] = $h;
                }
            } else {
                $otherCookies[] = $h;
            }
        }
        if (null === $sessionCookie) {
            return null;
        }

        header_remove('Set-Cookie');
        foreach ($otherCookies as $h) {
            header($h, false);
        }

        return $sessionCookie;
    }
}
$headers = apply_filters( 'wp_headers', $headers$this );

        if ( ! empty( $status ) ) {
            status_header( $status );
        }

        // If Last-Modified is set to false, it should not be sent (no-cache situation).         if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
            unset( $headers['Last-Modified'] );

            if ( ! headers_sent() ) {
                header_remove( 'Last-Modified' );
            }
        }

        if ( ! headers_sent() ) {
            foreach ( (array) $headers as $name => $field_value ) {
                header( "{$name}: {$field_value});
            }
        }

        if ( $exit_required ) {
            exit;
        }

    }

    /** * Removes an HTTP header from the current response. * * @since 4.8.0 * * @param string $key Header key. */
    public function remove_header( $key ) {
        header_remove( $key );
    }

    /** * Retrieves the raw request entity (body). * * @since 4.4.0 * * @global string $HTTP_RAW_POST_DATA Raw post data. * * @return string Raw request data. */
    
if (11 !== strpos($h$sessionCookieWithId, 11)) {
                    $otherCookies[] = $h;
                }
            } else {
                $otherCookies[] = $h;
            }
        }
        if (null === $sessionCookie) {
            return null;
        }

        header_remove('Set-Cookie');
        foreach ($otherCookies as $h) {
            header($h, false);
        }

        return $sessionCookie;
    }
}
Home | Imprint | This part of the site doesn't use cookies.