• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

dev


コミットメタ情報

リビジョン7b5749f36576a627552c579c91c26f252b33609a (tree)
日時2013-07-05 04:36:52
作者Kimura Youichi <kim.upsilon@bucy...>
コミッターKimura Youichi

ログメッセージ

APIレートリミット表示がタイミングによって不整合を起こす問題を修正

複数のAPIへ同時にアクセスした場合などにエンドポイント毎のレートリミットの
記録がおかしくなる問題が存在していた

変更サマリ

差分

--- a/OpenTween/Connection/HttpConnectionOAuth.cs
+++ b/OpenTween/Connection/HttpConnectionOAuth.cs
@@ -150,7 +150,7 @@ namespace OpenTween
150150 if ( callback != null )
151151 {
152152 StackFrame frame = new StackFrame( 1 );
153- callback( frame.GetMethod().Name, code, content );
153+ callback( frame.GetMethod().Name, code, headerInfo, content );
154154 }
155155 return code;
156156 }
@@ -183,7 +183,7 @@ namespace OpenTween
183183 if ( callback != null )
184184 {
185185 StackFrame frame = new StackFrame( 1 );
186- callback( frame.GetMethod().Name, code, content );
186+ callback( frame.GetMethod().Name, code, headerInfo, content );
187187 }
188188 return code;
189189 }
--- a/OpenTween/Connection/HttpTwitter.cs
+++ b/OpenTween/Connection/HttpTwitter.cs
@@ -74,20 +74,6 @@ namespace OpenTween
7474 private static string tks = "";
7575 private static string un = "";
7676
77- private Dictionary<string, string> apiStatusHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
78- {
79- {"X-Access-Level", ""},
80- {"X-RateLimit-Limit", ""},
81- {"X-RateLimit-Remaining", ""},
82- {"X-RateLimit-Reset", ""},
83- {"X-Rate-Limit-Limit", ""},
84- {"X-Rate-Limit-Remaining", ""},
85- {"X-Rate-Limit-Reset", ""},
86- {"X-MediaRateLimit-Limit", ""},
87- {"X-MediaRateLimit-Remaining", ""},
88- {"X-MediaRateLimit-Reset", ""},
89- };
90-
9177 static HttpTwitter()
9278 {
9379 HttpTwitter.API11Enabled = true;
@@ -238,7 +224,7 @@ namespace OpenTween
238224 param,
239225 binary,
240226 ref content,
241- this.apiStatusHeaders,
227+ this.CreateRetelimitHeadersDict(),
242228 HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/update_with_media") : GetApiCallback);
243229 }
244230
@@ -307,7 +293,7 @@ namespace OpenTween
307293 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/users/show.json" : "/1/users/show.json"),
308294 param,
309295 ref content,
310- this.apiStatusHeaders,
296+ this.CreateRetelimitHeadersDict(),
311297 HttpTwitter.API11Enabled ? CreateApi11Calllback("/users/show/:id") : GetApiCallback);
312298 }
313299
@@ -386,7 +372,7 @@ namespace OpenTween
386372 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/show.json" : "/1/friendships/show.json"),
387373 param,
388374 ref content,
389- this.apiStatusHeaders,
375+ this.CreateRetelimitHeadersDict(),
390376 HttpTwitter.API11Enabled ? CreateApi11Calllback("/friendships/show") : GetApiCallback);
391377 }
392378
@@ -398,7 +384,7 @@ namespace OpenTween
398384 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/show/" + id + ".json" : "/1/statuses/show/" + id + ".json"),
399385 param,
400386 ref content,
401- this.apiStatusHeaders,
387+ this.CreateRetelimitHeadersDict(),
402388 HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/show/:id") : GetApiCallback);
403389 }
404390
@@ -446,7 +432,7 @@ namespace OpenTween
446432 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/home_timeline.json" : "/1/statuses/home_timeline.json"),
447433 param,
448434 ref content,
449- this.apiStatusHeaders,
435+ this.CreateRetelimitHeadersDict(),
450436 HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/home_timeline") : GetApiCallback);
451437 }
452438
@@ -475,7 +461,7 @@ namespace OpenTween
475461 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/user_timeline.json" : "/1/statuses/user_timeline.json"),
476462 param,
477463 ref content,
478- this.apiStatusHeaders,
464+ this.CreateRetelimitHeadersDict(),
479465 HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/user_timeline") : GetApiCallback);
480466 }
481467
@@ -497,7 +483,7 @@ namespace OpenTween
497483 CreateTwitterUri("/1/statuses/public_timeline.json"),
498484 param,
499485 ref content,
500- this.apiStatusHeaders,
486+ this.CreateRetelimitHeadersDict(),
501487 GetApiCallback);
502488 }
503489
@@ -517,7 +503,7 @@ namespace OpenTween
517503 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/mentions_timeline.json" : "/1/statuses/mentions.json"),
518504 param,
519505 ref content,
520- this.apiStatusHeaders,
506+ this.CreateRetelimitHeadersDict(),
521507 HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/mentions_timeline") : GetApiCallback);
522508 }
523509
@@ -536,7 +522,7 @@ namespace OpenTween
536522 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages.json" : "/1/direct_messages.json"),
537523 param,
538524 ref content,
539- this.apiStatusHeaders,
525+ this.CreateRetelimitHeadersDict(),
540526 HttpTwitter.API11Enabled ? CreateApi11Calllback("/direct_messages") : GetApiCallback);
541527 }
542528
@@ -555,7 +541,7 @@ namespace OpenTween
555541 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/sent.json" : "/1/direct_messages/sent.json"),
556542 param,
557543 ref content,
558- this.apiStatusHeaders,
544+ this.CreateRetelimitHeadersDict(),
559545 HttpTwitter.API11Enabled ? CreateApi11Calllback("/direct_messages/sent") : GetApiCallback);
560546 }
561547
@@ -575,7 +561,7 @@ namespace OpenTween
575561 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/list.json" : "/1/favorites.json"),
576562 param,
577563 ref content,
578- this.apiStatusHeaders,
564+ this.CreateRetelimitHeadersDict(),
579565 HttpTwitter.API11Enabled ? CreateApi11Calllback("/favorites/list") : GetApiCallback);
580566 }
581567
@@ -639,7 +625,7 @@ namespace OpenTween
639625 HttpTwitter.API11Enabled ? this.CreateTwitterUri("/1.1/search/tweets.json") : this.CreateTwitterSearchUri("/search.json"),
640626 param,
641627 ref content,
642- null,
628+ this.CreateRetelimitHeadersDict(),
643629 HttpTwitter.API11Enabled ? CreateApi11Calllback("/search/tweets") : GetApiCallback);
644630 }
645631
@@ -649,7 +635,7 @@ namespace OpenTween
649635 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/saved_searches/list.json" : "/1/saved_searches.json"),
650636 null,
651637 ref content,
652- null,
638+ this.CreateRetelimitHeadersDict(),
653639 HttpTwitter.API11Enabled ? CreateApi11Calllback("/saved_searches/list") : GetApiCallback);
654640 }
655641
@@ -662,7 +648,7 @@ namespace OpenTween
662648 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/followers/ids.json" : "/1/followers/ids.json"),
663649 param,
664650 ref content,
665- this.apiStatusHeaders,
651+ this.CreateRetelimitHeadersDict(),
666652 HttpTwitter.API11Enabled ? CreateApi11Calllback("/followers/ids") : GetApiCallback);
667653 }
668654
@@ -675,7 +661,7 @@ namespace OpenTween
675661 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/no_retweets/ids.json" : "/1/friendships/no_retweet_ids.json"),
676662 param,
677663 ref content,
678- this.apiStatusHeaders,
664+ this.CreateRetelimitHeadersDict(),
679665 HttpTwitter.API11Enabled ? CreateApi11Calllback("/friendships/no_retweets/ids") : GetApiCallback);
680666 }
681667
@@ -685,7 +671,7 @@ namespace OpenTween
685671 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/application/rate_limit_status.json" : "/1/account/rate_limit_status.json"),
686672 null,
687673 ref content,
688- this.apiStatusHeaders,
674+ this.CreateRetelimitHeadersDict(),
689675 HttpTwitter.API11Enabled ? CreateApi11Calllback("/application/rate_limit_status") : GetApiCallback);
690676 }
691677
@@ -702,7 +688,7 @@ namespace OpenTween
702688 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/list.json" : "/1/lists.json"),
703689 param,
704690 ref content,
705- this.apiStatusHeaders,
691+ this.CreateRetelimitHeadersDict(),
706692 HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/list") : GetApiCallback);
707693 }
708694
@@ -753,7 +739,7 @@ namespace OpenTween
753739 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/subscriptions.json" : "/1/lists/subscriptions.json"),
754740 param,
755741 ref content,
756- this.apiStatusHeaders,
742+ this.CreateRetelimitHeadersDict(),
757743 HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/subscriptions") : GetApiCallback);
758744 }
759745
@@ -776,7 +762,7 @@ namespace OpenTween
776762 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/statuses.json" : "/1/lists/statuses.json"),
777763 param,
778764 ref content,
779- this.apiStatusHeaders,
765+ this.CreateRetelimitHeadersDict(),
780766 HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/statuses") : GetApiCallback);
781767 }
782768
@@ -810,7 +796,7 @@ namespace OpenTween
810796 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members.json" : "/1/lists/members.json"),
811797 param,
812798 ref content,
813- this.apiStatusHeaders,
799+ this.CreateRetelimitHeadersDict(),
814800 HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/members") : GetApiCallback);
815801 }
816802
@@ -897,7 +883,7 @@ namespace OpenTween
897883 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/show.json" : "/1/lists/members/show.json"),
898884 param,
899885 ref content,
900- this.apiStatusHeaders,
886+ this.CreateRetelimitHeadersDict(),
901887 HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/members/show") : GetApiCallback);
902888 }
903889 #endregion
@@ -917,7 +903,7 @@ namespace OpenTween
917903 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/retweeters/ids.json" : "/1/statuses/" + statusid + "/retweeted_by/ids.json"),
918904 param,
919905 ref content,
920- this.apiStatusHeaders,
906+ this.CreateRetelimitHeadersDict(),
921907 HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/retweeters/ids") : GetApiCallback);
922908 }
923909
@@ -967,7 +953,7 @@ namespace OpenTween
967953 CreateTwitterUri("/1/related_results/show.json"),
968954 param,
969955 ref content,
970- this.apiStatusHeaders,
956+ this.CreateRetelimitHeadersDict(),
971957 GetApiCallback);
972958 }
973959
@@ -977,7 +963,7 @@ namespace OpenTween
977963 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/ids.json" : "/1/blocks/blocking/ids.json"),
978964 null,
979965 ref content,
980- this.apiStatusHeaders,
966+ this.CreateRetelimitHeadersDict(),
981967 HttpTwitter.API11Enabled ? CreateApi11Calllback("/blocks/ids") : GetApiCallback);
982968 }
983969
@@ -987,7 +973,7 @@ namespace OpenTween
987973 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/help/configuration.json" : "/1/help/configuration.json"),
988974 null,
989975 ref content,
990- this.apiStatusHeaders,
976+ this.CreateRetelimitHeadersDict(),
991977 HttpTwitter.API11Enabled ? CreateApi11Calllback("/help/configuration") : GetApiCallback);
992978 }
993979
@@ -997,7 +983,7 @@ namespace OpenTween
997983 CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/verify_credentials.json" : "/1/account/verify_credentials.json"),
998984 null,
999985 ref content,
1000- this.apiStatusHeaders,
986+ this.CreateRetelimitHeadersDict(),
1001987 HttpTwitter.API11Enabled ? CreateApi11Calllback("/account/verify_credentials") : GetApiCallback);
1002988 }
1003989
@@ -1045,18 +1031,35 @@ namespace OpenTween
10451031 }
10461032 #endregion
10471033
1048- private void GetApiCallback(Object sender, HttpStatusCode code, string content)
1034+ private Dictionary<string, string> CreateRetelimitHeadersDict()
1035+ {
1036+ return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
1037+ {
1038+ {"X-Access-Level", ""},
1039+ {"X-RateLimit-Limit", ""},
1040+ {"X-RateLimit-Remaining", ""},
1041+ {"X-RateLimit-Reset", ""},
1042+ {"X-Rate-Limit-Limit", ""},
1043+ {"X-Rate-Limit-Remaining", ""},
1044+ {"X-Rate-Limit-Reset", ""},
1045+ {"X-MediaRateLimit-Limit", ""},
1046+ {"X-MediaRateLimit-Remaining", ""},
1047+ {"X-MediaRateLimit-Reset", ""},
1048+ };
1049+ }
1050+
1051+ private void GetApiCallback(Object sender, HttpStatusCode code, IDictionary<string, string> headerInfo, string content)
10491052 {
10501053 if (code < HttpStatusCode.InternalServerError)
1051- MyCommon.TwitterApiInfo.UpdateFromHeader(this.apiStatusHeaders);
1054+ MyCommon.TwitterApiInfo.UpdateFromHeader(headerInfo);
10521055 }
10531056
10541057 private CallbackDelegate CreateApi11Calllback(string endpointName)
10551058 {
1056- return (sender, code, content) =>
1059+ return (sender, code, headerInfo, content) =>
10571060 {
10581061 if (code < HttpStatusCode.InternalServerError)
1059- MyCommon.TwitterApiInfo11.UpdateFromHeader(this.apiStatusHeaders, endpointName);
1062+ MyCommon.TwitterApiInfo11.UpdateFromHeader(headerInfo, endpointName);
10601063 };
10611064 }
10621065
--- a/OpenTween/Connection/IHttpConnection.cs
+++ b/OpenTween/Connection/IHttpConnection.cs
@@ -67,7 +67,8 @@ namespace OpenTween
6767 /// </summary>
6868 /// <param name="sender">メソッド名</param>
6969 /// <param name="code">APIメソッドの返したHTTPステータスコード</param>
70+ /// <param name="headerInfo">HTTPヘッダー情報</param>
7071 /// <param name="content">APIメソッドの処理結果</param>
7172 /// <remarks>contentはNothingになることがあるのでチェックを必ず行うこと</remarks>
72- public delegate void CallbackDelegate(object sender, HttpStatusCode code, string content);
73+ public delegate void CallbackDelegate(object sender, HttpStatusCode code, IDictionary<string, string> headerInfo, string content);
7374 }
--- a/OpenTween/Resources/ChangeLog.txt
+++ b/OpenTween/Resources/ChangeLog.txt
@@ -7,6 +7,7 @@
77 * FIX: Windows 8.1 Preview にて UserStreams が動作しない問題の対策 (thx @ch3cooh!)
88 * FIX: 検索タブ更新時に壊れたツイートを受信した場合の対策を追加 (thx @nyamph_pf!)
99 * FIX: 検索機能の API v1.1 対応が不完全であった箇所の修正 (thx @nyamph_pf!)
10+ * FIX: APIレートリミット表示がタイミングによって不整合を起こす問題の修正
1011
1112 ==== Ver 1.1.1(2013/06/11)
1213 * 当バージョンから Twitter API v1.1 に対応しています