Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow GCM proxy config #910

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions PushSharp.Google/GcmConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Net;

namespace PushSharp.Google
{
Expand Down Expand Up @@ -38,6 +39,8 @@ public void OverrideUrl (string url)
{
GcmUrl = url;
}

public WebProxy Proxy { get; set; }
}
}

12 changes: 11 additions & 1 deletion PushSharp.Google/GcmServiceConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ public class GcmServiceConnection : IServiceConnection<GcmNotification>
public GcmServiceConnection (GcmConfiguration configuration)
{
Configuration = configuration;
http = new HttpClient ();
if (null != configuration.Proxy)
{
var httpHandler = new HttpClientHandler
{
Proxy = configuration.Proxy
};
http = new HttpClient(httpHandler, true);
} else
{
http = new HttpClient();
}

http.DefaultRequestHeaders.UserAgent.Clear ();
http.DefaultRequestHeaders.UserAgent.Add (new ProductInfoHeaderValue ("PushSharp", "3.0"));
Expand Down