Skip to content

Commit 4e35c65

Browse files
committed
remove build target
1 parent c33fe9a commit 4e35c65

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/Http/SubDBApi.cs

+10-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Net;
77
using System.Net.Http;
88
using System.Net.Http.Headers;
9-
using System.Text;
109
using System.Threading.Tasks;
1110

1211
namespace SubDBSharp
@@ -81,7 +80,7 @@ public Task<Response> DownloadSubtitle(string hash, params string[] languages)
8180
public Task<Response> UploadSubtitle(string subtitle, string movie)
8281
{
8382
var uriBuilder = new UriBuilder(BaseAddress) { Query = "action=upload" };
84-
Request request = BuildRequest(uriBuilder.Uri, HttpMethod.Post, CreateFormContent(subtitle, movie));
83+
Request request = BuildRequest(uriBuilder.Uri, HttpMethod.Post, BuildFormContent(subtitle, movie));
8584
return SendDataAsync(request);
8685
}
8786

@@ -137,29 +136,26 @@ protected virtual Request BuildRequest(Uri endPoint, HttpMethod method, HttpCont
137136
return new Request(endPoint, method, body);
138137
}
139138

140-
private static HttpContent CreateFormContent(string subtitle, string movie)
139+
private static HttpContent BuildFormContent(string subtitle, string movie)
141140
{
142-
const string dispositionType = "form-data";
143-
144141
var content = new MultipartFormDataContent("xYzZY");
145142

146-
// hash info
147-
StringContent stringContent = stringContent = new StringContent(Utils.GetMovieHash(movie));
148-
stringContent.Headers.ContentDisposition = new ContentDispositionHeaderValue(dispositionType)
143+
// hash content
144+
var stringContent = new StringContent(Utils.GetMovieHash(movie));
145+
stringContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
149146
{
147+
DispositionType = "form-data",
150148
Name = "\"hash\""
151149
};
152150

153-
// subtitle file info
154-
FileStream fs = File.OpenRead(subtitle);
155-
var streamContent = new StreamContent(fs);
151+
// subtitle content
152+
var streamContent = new StreamContent(File.OpenRead(subtitle));
156153
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
157-
var dispo = new ContentDispositionHeaderValue(dispositionType)
154+
streamContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
158155
{
159156
Name = "\"file\"",
160157
FileName = $"\"{Path.GetFileName(subtitle)}\""
161158
};
162-
streamContent.Headers.ContentDisposition = dispo;
163159

164160
// add contents to form
165161
content.Add(stringContent);
@@ -170,9 +166,8 @@ private static HttpContent CreateFormContent(string subtitle, string movie)
170166

171167
public void Dispose()
172168
{
173-
// will dispose _handler aswell (mentioned in contructor)
169+
// calling dispose in _httClient handler will also dispose _httpClientHandler. (set in contructor)
174170
_httpClient.Dispose();
175-
//_httpClientHandler.Dispose();
176171
}
177172
}
178173
}

src/SubDBSharp.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>

0 commit comments

Comments
 (0)