GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Plack::Middleware::Headers(3) User Contributed Perl Documentation Plack::Middleware::Headers(3)

Plack::Middleware::Headers - modify HTTP response headers

version 0.11

  use Plack::Builder;
  builder {
      enable 'Headers',
        set    => ['X-Plack-One' => '1'],
        append => ['X-Plack-Two' => '2'],
        unset  => ['X-Plack-Three'];
      enable 'Headers',
        code   => '404',
        set    => ['X-Robots-Tag' => 'noindex, noarchive, follow'];
      enable 'Headers',
        when   => ['Content-Type' => qr{^text/}],
        set    => ['Content-Type' => 'text/plain'];
      sub {['200', [], ['hello']]};
  };

This Plack::Middleware simplifies creation ("set" or "append"), deletion ("unset"), and modification ("set") of PSGI response headers. The modification can be enabled based on response code ("code") or existing response headers("when"). Use Plack::Middleware::Conditional to enable the middleware based in request headers.

Overwrites existent header(s).
Remove existing header(s).
Add header(s).
Optional HTTP response code that modification of response headers is limited to.
Optional check on the response headers that must be true to actually modify headers. Either one provides a list of headers for which one of them must match. Matching can be tested against:

    header => undef,    # missing header
    header => $scalar   # exact value
    header => /$regexp/ # regular expression
    

Alternatively one can check with a code reference that all response headers are passed to as list.

This module is an extened fork of Plack::Middleware::Header, originally created by Masahiro Chiba. Additional contributions by Wallace Reis.

Plack::Middleware, Plack::Builder

Jakob Voß

This software is copyright (c) 2014 by Jakob Voß.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2014-03-22 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.