Skip to content

Commit 3726cb5

Browse files
committed
Fix bugs for long pull and nested union
1 parent 6cc73f6 commit 3726cb5

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

Dropbox.Api/Dropbox.Api.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>$id$</id>
5-
<version>2.0.0</version>
5+
<version>2.0.1</version>
66
<title>Dropbox v2 API Beta</title>
77
<authors>Dropbox Inc</authors>
88
<owners>Dropbox Inc</owners>
@@ -12,7 +12,7 @@
1212
<iconUrl>https://cf.dropboxstatic.com/static/images/icons/blue_dropbox_glyph.png</iconUrl>
1313
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1414
<description>Portable class library for accessing the Dropbox v2 API</description>
15-
<releaseNotes>Preview Release. Major code refactoring. Improved json parsing performance. Added shared folder endpoints.</releaseNotes>
15+
<releaseNotes>Preview Release. Bug fixes.</releaseNotes>
1616
<copyright>Copyright (c) Dropbox Inc. 2015</copyright>
1717
<tags>Dropbox Api</tags>
1818
</metadata>

Dropbox.Api/DropboxRequestHandler.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,11 @@ private async Task<Result> RequestJsonString(
340340

341341
var request = new HttpRequestMessage(HttpMethod.Post, uri);
342342

343-
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.options.OAuth2AccessToken);
343+
if (host != HostType.ApiNotify)
344+
{
345+
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.options.OAuth2AccessToken);
346+
}
347+
344348
request.Headers.TryAddWithoutValidation("User-Agent", this.options.UserAgent);
345349

346350
if (this.selectUser != null)
@@ -576,6 +580,11 @@ internal class HostType
576580
/// Host type for api content.
577581
/// </summary>
578582
public const string ApiContent = "content";
583+
584+
/// <summary>
585+
/// Host type for api notify.
586+
/// </summary>
587+
public const string ApiNotify = "notify";
579588
}
580589

581590
/// <summary>
@@ -593,6 +602,11 @@ internal sealed class DrpoboxRequestHandlerOptions
593602
/// </summary>
594603
private const string DefaultApiContentDomain = "content.dropboxapi.com";
595604

605+
/// <summary>
606+
/// The default api notify domain
607+
/// </summary>
608+
private const string DefaultApiNotifyDomain = "notify.dropboxapi.com";
609+
596610
/// <summary>
597611
/// The base user agent, used to construct all user agent strings.
598612
/// </summary>
@@ -613,6 +627,8 @@ internal sealed class DrpoboxRequestHandlerOptions
613627
/// this is for internal Dropbox use only.</param>
614628
/// <param name="apiContentHostname">The hostname that will process api content requests;
615629
/// this is for internal Dropbox use only.</param>
630+
/// <param name="apiNotifyHostname">The hostname that will process api notify requests;
631+
/// this is for internal Dropbox use only.</param>
616632
/// <param name="httpClient">The custom http client. If not provided, a default
617633
/// http client will be created.</param>
618634
public DrpoboxRequestHandlerOptions(
@@ -621,6 +637,7 @@ public DrpoboxRequestHandlerOptions(
621637
string userAgent = null,
622638
string apiHostname = DefaultApiDomain,
623639
string apiContentHostname = DefaultApiContentDomain,
640+
string apiNotifyHostname = DefaultApiNotifyDomain,
624641
HttpClient httpClient = null)
625642
{
626643
var name = new AssemblyName(typeof(DrpoboxRequestHandlerOptions).Assembly.FullName);
@@ -636,7 +653,8 @@ public DrpoboxRequestHandlerOptions(
636653
this.HostMap = new Dictionary<string, string>
637654
{
638655
{ HostType.Api, apiHostname },
639-
{ HostType.ApiContent, apiContentHostname }
656+
{ HostType.ApiContent, apiContentHostname },
657+
{ HostType.ApiNotify, apiNotifyHostname }
640658
};
641659
}
642660

Dropbox.Api/Files/MediaInfo.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,22 @@ protected override Metadata Create()
301301
}
302302

303303
/// <summary>
304-
/// <para>Decode fields without ensuring start and end object.</para>
304+
/// <para>Set given field.</para>
305305
/// </summary>
306+
/// <param name="value">The field value.</param>
307+
/// <param name="fieldName">The field name.</param>
306308
/// <param name="reader">The json reader.</param>
307-
/// <returns>The decoded object.</returns>
308-
public override Metadata DecodeFields(enc.IJsonReader reader)
309+
protected override void SetField(Metadata value, string fieldName, enc.IJsonReader reader)
309310
{
310-
return new Metadata(MediaMetadata.Decoder.DecodeFields(reader));
311+
switch (fieldName)
312+
{
313+
case "metadata":
314+
value.Value = MediaMetadata.Decoder.Decode(reader);
315+
break;
316+
default:
317+
SkipProperty(reader);
318+
break;
319+
}
311320
}
312321
}
313322

0 commit comments

Comments
 (0)