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

added support for headers on LongPollingTransport #19

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions cometd/client/transport/HttpClientTransport.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Text;

Expand All @@ -9,10 +10,12 @@ public abstract class HttpClientTransport : ClientTransport
{
private String url;
private CookieCollection cookieCollection;
private WebHeaderCollection headerCollection;

protected HttpClientTransport(String name, IDictionary<String, Object> options)
: base(name, options)
{
setHeaderCollection(new WebHeaderCollection());
}

protected String getURL()
Expand Down Expand Up @@ -41,5 +44,22 @@ protected internal void addCookie(Cookie cookie)
if (cookieCollection != null)
cookieCollection.Add(cookie);
}

protected WebHeaderCollection getHeaderCollection()
{
return headerCollection;
}

public void setHeaderCollection(WebHeaderCollection headerCollection)
{
this.headerCollection = headerCollection;
}

protected internal void addHeaders(NameValueCollection headers)
{
WebHeaderCollection headerCollection = this.headerCollection;
if (headerCollection != null)
headerCollection.Add(headers);
}
}
}
10 changes: 10 additions & 0 deletions cometd/client/transport/LongPollingTransport.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.IO;
using System.Runtime.Serialization.Json;
Expand Down Expand Up @@ -158,6 +159,10 @@ public override void send(ITransportListener listener, IList<IMutableMessage> me
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(getCookieCollection());

if (request.Headers == null)
request.Headers = new WebHeaderCollection();
request.Headers.Add(getHeaderCollection());

JavaScriptSerializer jsonParser = new JavaScriptSerializer();
String content = jsonParser.Serialize(ObjectConverter.ToListOfDictionary(messages));

Expand Down Expand Up @@ -278,6 +283,11 @@ private static void TimeoutCallback(object state, bool timedOut)
}
}

public void AddHeaders(NameValueCollection headers)
{
addHeaders(headers);
}


public class TransportExchange
{
Expand Down