Skip to content

Commit bb0acb5

Browse files
committed
Merge pull request andyburke#51 from jjay/master
Support for both version of WWWForm.headers
2 parents 034fbdd + b42fe16 commit bb0acb5

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/FormDataStream.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
namespace HTTP {
66

77
public class FormPart {
8-
string fieldName;
9-
string mimeType;
108
byte[] header;
119
Stream contents;
1210
int position = 0;
@@ -51,6 +49,11 @@ public int Read(byte[] buffer, int offset, int size){
5149
position += bytesToWrite;
5250
return writed;
5351
}
52+
53+
public void Dispose(){
54+
header = null;
55+
contents.Close();
56+
}
5457
}
5558

5659
public class FormDataStream: Stream {
@@ -151,6 +154,13 @@ public void AddPart(FormPart part){
151154
}
152155
parts.Add(part);
153156
}
157+
158+
public override void Close(){
159+
foreach (var part in parts){
160+
part.Dispose();
161+
}
162+
base.Close();
163+
}
154164
}
155165

156166
}

src/Request.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,17 @@ public Request( string method, string uri, WWWForm form )
8989
this.method = method;
9090
this.uri = new Uri (uri);
9191
this.byteStream = new MemoryStream(form.data);
92-
foreach ( KeyValuePair<string,string> pair in form.headers )
93-
{
94-
this.AddHeader(pair.Key,pair.Value);
95-
}
92+
#if UNITY_5
93+
foreach ( var entry in form.headers )
94+
{
95+
this.AddHeader( entry.Key, entry.Value );
96+
}
97+
#else
98+
foreach ( DictionaryEntry entry in form.headers )
99+
{
100+
this.AddHeader( (string)entry.Key, (string)entry.Value );
101+
}
102+
#endif
96103
}
97104

98105
public Request( string method, string uri, Hashtable data )

0 commit comments

Comments
 (0)