Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix C# examples for HttpWebRequest.Headers property

  • Loading branch information...
commit 722bb0279445d2c4478cc21b5da1436e3db24f0b 1 parent 24a4af1
@zdne zdne authored
Showing with 18 additions and 2 deletions.
  1. +18 −2 csharp.html
View
20 csharp.html
@@ -6,8 +6,24 @@
request.ContentType = "<%= @contentType %>";
<% end %>
<% if @headers and @helpers.isNotEmpty @headers: %>
- <% for header, value of @headers: %>request.Headers.Add(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
-<% end %><% end %>
+ <% for header, value of @headers: %>
+ <% header = header.toLowerCase() %>
+ <% if header is 'accept': %>request.Accept = "<%= @helpers.escape value %>";
+ <% else if header is 'connection': %>request.Connection = "<%= @helpers.escape value %>";
+ <% else if header is 'content-length': %>request.ContentLength = "<%= @helpers.escape value %>";
+ <% else if header is 'expect': %>request.Expect = "<%= @helpers.escape value %>";
+ <% else if header is 'date': %>request.Date = "<%= @helpers.escape value %>";
+ <% else if header is 'host': %>request.Host = "<%= @helpers.escape value %>";
+ <% else if header is 'if-modified-since': %>request.IfModifiedSince = "<%= @helpers.escape value %>";
+ <% else if header is 'range': %>request.AddRange = "<%= @helpers.escape value %>";
+ <% else if header is 'referer': %>request.Referer = "<%= @helpers.escape value %>";
+ <% else if header is 'transfer-encoding': %>request.TransferEncoding = "<%= @helpers.escape value %>";
+ <% else if header is 'user-agent': %>request.UserAgent = "<%= @helpers.escape value %>";
+ <% else if header is 'connection': %>request.Connection = "<%= @helpers.escape value %>";
+ <% else: %>request.Headers.Add(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
+ <% end %>
+ <% end %>
+<% end %>
<% if @body?.length > 0: %>
<% if @method.toUpperCase() is 'POST' or @method.toUpperCase() is 'PUT' or @method.toUpperCase() is 'DELETE' or @body.length > 0: %>
using (var writer = new System.IO.StreamWriter(request.GetRequestStream())) {
Please sign in to comment.
Something went wrong with that request. Please try again.