Expectation Failed というエラー

Android からPOSTしたときに、サーバ側の処理は正常終了してるのに、Expectation Failedというエラーが帰ってきていて悩んだ。

仕組みについては、以下のエントリで理解できました。

Twitter APIの417 Expectation Failed対策 – エスカフラーチェLLC

そもそも417 Expectation Failedとは何か?ということですが、これを理解するには100 Continueというレスポンスについてあわせて知っておく必要があります。

今回、ローカルで動かしている時は問題なかったけど、ステージング環境で動かそうとした際に、Expectation Failedが発生した。 リバースプロキシを挟むようになったことがトリガーになったようです。

javaの場合の回避方法は、以下。

  final DefaultHttpClient httpClient = new DefaultHttpClient();
  httpClient.getParams().setParameter("http.protocol.expect-continue", false); // 100-continue の抑制

HttpClientのインスタンスに、”http.protocol.expect-continue” = false を設定する。

これで、回避できました。

1件のコメント

  • I’m impressed, I have to say. Actually rarely do I encounter a weblog that’s both educative and entertaining, and let me inform you, you have got hit the nail on the head. Your thought is outstanding; the problem is something that not enough individuals are speaking intelligently about. I’m very completely satisfied that I stumbled throughout this in my search for one thing relating to this.

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


reCaptcha の認証期間が終了しました。ページを再読み込みしてください。

This site uses Akismet to reduce spam. Learn how your comment data is processed.