Navigation Menu

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

Add vb template #7

Merged
merged 1 commit into from Jun 11, 2013
Merged
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
30 changes: 30 additions & 0 deletions vb.html
@@ -0,0 +1,30 @@
<section name="vb" class="vb">
<p class="ioDesc">Request</p>
<pre class="incoming"><code class="language-vb">
Dim request = TryCast(System.Net.WebRequest.Create("<%= @apiUrl %><%= @url %>"), System.Net.HttpWebRequest)
request.Method = "<%= @method.toUpperCase() %>"
<% if @contentType: %>
request.ContentType = "<%= @contentType %>"
<% end %>
<% if @headers: %>
<% for header, value of @headers: %>request.Headers.Add(<%= @helpers.escape header %>, <%= @helpers.escape value %>)
<% end %><% end %>
<% if @helpers.isNotEmpty @body: %>
<% if @method.toUpperCase() is 'POST' or @method.toUpperCase() is 'PUT' or @method.toUpperCase() is 'DELETE': %>
Using writer = New System.IO.StreamWriter(request.GetRequestStream())
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("<%= @body.replace(/"/g, "'") %>")
request.ContentLength = byteArray.Length
writer.Write(byteArray)
writer.Close()
End Using
<% end %>
<% else: %>
request.ContentLength = 0
<% end %>
Dim responseContent As String
Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
Using reader = New System.IO.StreamReader(response.GetResponseStream())
responseContent = reader.ReadToEnd()
End Using
End Using
</code></pre></section>