Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #65 from ofalk/master
Browse files Browse the repository at this point in the history
Optional parameter user_agent
  • Loading branch information
bastelfreak authored Mar 30, 2018
2 parents 90b44a7 + 72551a2 commit fa55928
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
# [*cookies*]
# An optional array of cookies to add to the HTTP request for the download.
#
# [*user_agent*]
# The optional user agent string to be sent when downloading.
#
# === Examples
#
# To download dotnet 4.0
Expand Down Expand Up @@ -67,7 +70,8 @@
$proxy_password = '',
$is_password_secure = true,
Optional[Integer] $timeout = undef,
Optional[Array[String]] $cookies = undef
Optional[Array[String]] $cookies = undef,
Optional[String] $user_agent = undef
) {

if $destination_file {
Expand Down
5 changes: 5 additions & 0 deletions spec/defines/download_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
$proxyUser = ''
$proxyPassword = ''
if ($proxyAddress -ne '') {
if (!($proxyAddress.StartsWith('http://') -or $proxyAddress.StartsWith('https://'))) {
$proxyAddress = 'http://' + $proxyAddress
Expand Down Expand Up @@ -116,6 +117,7 @@
$proxyUser = ''
$proxyPassword = ''
if ($proxyAddress -ne '') {
if (!($proxyAddress.StartsWith('http://') -or $proxyAddress.StartsWith('https://'))) {
$proxyAddress = 'http://' + $proxyAddress
Expand Down Expand Up @@ -187,6 +189,7 @@
$proxyUser = 'test-user'
$proxyPassword = 'test-secure'
if ($proxyAddress -ne '') {
if (!($proxyAddress.StartsWith('http://') -or $proxyAddress.StartsWith('https://'))) {
$proxyAddress = 'http://' + $proxyAddress
Expand Down Expand Up @@ -260,6 +263,7 @@
$proxyUser = 'test-user'
$proxyPassword = 'test'
if ($proxyAddress -ne '') {
if (!($proxyAddress.StartsWith('http://') -or $proxyAddress.StartsWith('https://'))) {
$proxyAddress = 'http://' + $proxyAddress
Expand Down Expand Up @@ -309,6 +313,7 @@
$proxyUser = ''
$proxyPassword = ''
if ($proxyAddress -ne '') {
if (!($proxyAddress.StartsWith('http://') -or $proxyAddress.StartsWith('https://'))) {
$proxyAddress = 'http://' + $proxyAddress
Expand Down
3 changes: 3 additions & 0 deletions templates/download.ps1.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ $webclient = New-Object System.Net.WebClient
$proxyAddress = '<%= @proxy_address %>'
$proxyUser = '<%= @proxy_user %>'
$proxyPassword = '<%= @proxy_password %>'
<% if @user_agent %>
$webclient.Headers['User-Agent'] = '<%= @user_agent %>'
<% end %>

if ($proxyAddress -ne '') {
if (!($proxyAddress.StartsWith('http://') -or $proxyAddress.StartsWith('https://'))) {
Expand Down

0 comments on commit fa55928

Please sign in to comment.