7

POST がローカル開発サーバーで機能するように、Google Cloud Endpoints クラスの GZipContent を無効にしたいと考えています。

最新の GPE リリースでは、次のエンドポイント ビルダーが生成されます。

public static final class Builder extends AbstractGoogleJsonClient.Builder {
    public Builder(HttpTransport transport, JsonFactory jsonFactory,
        HttpRequestInitializer httpRequestInitializer) {
      super(
          transport,
          jsonFactory,
          ...);
    }

Google のドキュメントでは、次のように使用することを推奨しています。

Myendpoint.Builder endpointBuilder = new Myendpoint.Builder(
                    AndroidHttp.newCompatibleTransport(),
                    new GsonFactory(),
                    credential);

エンドポイントの GZipContent を無効にする方法を知っている人はいますか?

ありがとう。

4

3 に答える 3

11

以下を使用できます。

builder.setGoogleClientRequestInitializer(new TictactoeRequestInitializer() {
     protected void initializeTictactoeRequest(TictactoeRequest<?> request) {
         request.setDisableGZipContent(true);
     }
   });

TictactoeRequestアプリケーションに適したクラスに置き換えます。

于 2013-03-13T18:33:17.000 に答える
0

私が見たエラーをグーグルで調べている人にとっては、それは java.io.EOFException でしたが、開発サーバーでのみでした。OPの質問に記載されている例を使用して、これを修正する方法は次のとおりです。

Myendpoint myendpointClient = new Myendpoint.Builder(
                AndroidHttp.newCompatibleTransport(),
                new GsonFactory(),
                credential).build();
EndpointService svcCall = myendpointClient.endpointService("firstArg");
// Note, I didn't call "execute()", as normal!
svcCall.setDisableGZipContent(true);
// This is also a handy place to set http headers, etc
svcCall.getRequestHeaders().set("x-oddballhdr","OddballValue");
// It's now time to call execute()
svcCall.execute();

これは、他の役立つ回答よりも少し簡単かもしれません。

于 2014-12-19T00:12:22.867 に答える