GWT нас радуе

May 26, 2009 16:28


калі адказ сэрвера вялікі, тады і GWT-RPC
RPCServletUtils
public static void writeResponse(ServletContext servletContext, HttpServletResponse response, String responseContent, boolean gzipResponse)
{
  byte[] responseBytes = responseContent.getBytes(CHARSET_UTF8);

ByteArrayOutputStream output = new ByteArrayOutputStream(responseBytes.length);
  gzipOutputStream = new GZIPOutputStream(output);
  responseBytes = output.toByteArray();
  ...
  response.getOutputStream().write(responseBytes);
}

і SAP Server

GzipResponseStream
public void write(byte b[], int off, int len)
{
  if( len <= buf.length )
    System.arraycopy(b, off, buf, count, len);
  else
    gzipmultistream.write(servletoutput, b, off, len);
}

абодва зіпуюць кантэнт •

на кліенце браўзер раззіпоўвае адказ ад сэрвера адын раз і аддае кантэнт GWT,
а той проста спрабуе гэта дэкадаваць як json • і падае зы страшнай сілай

com.google.gwt.http.client.Request
private void fireOnResponseReceivedImpl(RequestCallback callback)
{
  Response response = createResponse(xmlHttp);
  callback.onResponseReceived(this, response);
}

RequestCallbackAdapter
onResponseReceived()
{
  String encodedResponse = response.getText();
  // but the this is zipped json, not encoded text.
  // and thus
  caught = new InvocationException(encodedResponse);
}

тры выйсьці:
забараніць серваку зіпаваць усе адказы з тыпам "application/json"
перапісаць gwt-ны RemoteServiceServlet: shouldCompressResponse() { return false; }
або напісаць у гугл, што ў іх памылка-недаробка

ўэб, праца, gwt

Previous post Next post
Up