Skip to content

Commit

Permalink
Add parameter for AddDefaultCharset virtual host directive
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Cleal committed Oct 17, 2014
1 parent bb7ee1a commit a92b8fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,10 @@ Specifies the use of either a LogFormat nickname or a custom format string for t

Specifies that only requests with particular environment variables be logged. Defaults to 'undef'.

#####`add_default_charset`

Sets [AddDefaultCharset](http://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset), a default value for the media charset, which is added to text/plain and text/html responses.

#####`add_listen`

Determines whether the vhost creates a Listen statement. The default value is 'true'.
Expand Down
11 changes: 11 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
$passenger_min_instances = undef,
$passenger_start_timeout = undef,
$passenger_pre_start = undef,
$add_default_charset = undef,
) {
# The base class must be included first because it is used by parameter defaults
if ! defined(Class['apache']) {
Expand Down Expand Up @@ -800,6 +801,16 @@
content => template('apache/vhost/_passenger.erb'),
}

# Template uses:
# - $add_default_charset
if $add_default_charset {
concat::fragment { "${name}-charsets":
target => "${priority_real}-${filename}.conf",
order => 300,
content => template('apache/vhost/_charsets.erb'),
}
}

# Template uses no variables
concat::fragment { "${name}-file_footer":
target => "${priority_real}-${filename}.conf",
Expand Down
5 changes: 4 additions & 1 deletion spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@
'passenger_ruby' => '/usr/bin/ruby1.9.1',
'passenger_min_instances' => '1',
'passenger_start_timeout' => '600',
'passenger_pre_start' => 'http://localhost/myapp'
'passenger_pre_start' => 'http://localhost/myapp',
'add_default_charset' => 'UTF-8',
}
end
let :facts do
Expand Down Expand Up @@ -312,6 +313,7 @@
it { is_expected.to contain_concat__fragment('rspec.example.com-fastcgi') }
it { is_expected.to contain_concat__fragment('rspec.example.com-suexec') }
it { is_expected.to contain_concat__fragment('rspec.example.com-passenger') }
it { is_expected.to contain_concat__fragment('rspec.example.com-charsets') }
it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') }
end
context 'not everything can be set together...' do
Expand Down Expand Up @@ -390,6 +392,7 @@
it { is_expected.to_not contain_concat__fragment('rspec.example.com-custom_fragment') }
it { is_expected.to_not contain_concat__fragment('rspec.example.com-fastcgi') }
it { is_expected.to_not contain_concat__fragment('rspec.example.com-suexec') }
it { is_expected.to_not contain_concat__fragment('rspec.example.com-charsets') }
it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') }
end
end
Expand Down
4 changes: 4 additions & 0 deletions templates/vhost/_charsets.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% if @add_default_charset -%>

AddDefaultCharset <%= @add_default_charset %>
<% end -%>

0 comments on commit a92b8fb

Please sign in to comment.