Skip to content

Commit

Permalink
ensure connections are closed
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-lp committed May 14, 2015
1 parent fbd78b2 commit fcb697c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions c#.net/LiquidPlanner/LiquidPlanner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public LiquidPlanner(string username, string password)
private LpResponse request(String verb, String url, Object data)
{
HttpWebRequest request;
WebResponse response;
String uri;
LpResponse lp_response;

Expand All @@ -113,9 +112,12 @@ private LpResponse request(String verb, String url, Object data)
lp_response = new LpResponse();
try
{
response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
lp_response.response = reader.ReadToEnd();
using (response = request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream())) {
lp_response.response = reader.ReadToEnd();
}
}
}
catch (Exception e)
{
Expand Down
11 changes: 6 additions & 5 deletions vb.net/LiquidPlannerVB/LiquidPlanner.vb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Module LiquidPlanner

Private Function request(ByVal verb As String, ByVal url As String, ByRef data As Object) As LpResponse
Dim theRequest As HttpWebRequest
Dim response As WebResponse
Dim uri As String
Dim lp_response As LpResponse

Expand All @@ -95,9 +94,11 @@ Module LiquidPlanner

lp_response = New LpResponse()
Try
response = theRequest.GetResponse
Dim reader As StreamReader = New StreamReader(response.GetResponseStream)
lp_response.response = reader.ReadToEnd
Using response = theRequest.GetResponse
Using reader As StreamReader = New StreamReader(response.GetResponseStream)
lp_response.response = reader.ReadToEnd
End Using
End Using
Catch ex As Exception
lp_response.anError = ex
End Try
Expand Down Expand Up @@ -189,4 +190,4 @@ Module LiquidPlanner
aTask = liquidplanner.UpdateTask(aTask)
End Sub

End Module
End Module

0 comments on commit fcb697c

Please sign in to comment.