Surely a nasty bug! in RPCServletUtils.readContentAsUtf8

2010-07-12 Thread Shawn Brown
Hi,
 Can anyone suggest a work around for
http://code.google.com/p/google-web-toolkit/issues/detail?id=5109

I'll have to look at the src when I get time but this is nuts to me.

Does this work for you?

private String showRequestedMethod(ServletRequest request) throws
IOException, ServletException {

//requestCopy2=(HttpServletRequest) request;

//HttpServletRequest requestCopy =(HttpServletRequest) request;

String r1 = request.toString();
Log.info("request.length" + request.getContentLength());
String payload =
RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));
Log.info("payload: "+payload);
pay=payload;
RPCRequest rpc_request = RPC.decodeRequest(payload);
//  Log.info("rpc. method " + rpc_request.getMethod());
Log.info("r.ts "+request.toString());


Log.info("request.length" + request.getContentLength());
String r2= request.toString();
String payload2;
try {
payload2 = 
RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));
Log.info("payload2: "+payload2);

} catch (Exception e) {
Log.info("Why the #$% "+ e.getMessage());
e.printStackTrace();
}
Log.info("r.ts2 "+request.toString());

Log.info("Are r1 and r2 the same "+r1.equals(r2));

return rpc_request.getMethod().toString();
}

I get an error every time saying "Client did not send 197 bytes as
expected".  Why it's the same request that is passed into
RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));

Basically I am checking for authorization in a filter so I need to
find out what rpc method is being called.  Then if the user has auth,
I let it go through but then see an error when the method is really
called.  I call it twice in this method as an example to narrow down
what is failing.

Any help?  Please!

Shawn

PS. perhaps this is related
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/9b4a98d0d50d2752

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Surely a nasty bug! in RPCServletUtils.readContentAsUtf8

2010-07-12 Thread Paul Robinson
Search the archives for "Client did not send nn bytes as expected". It's
come up several times before, but I don't think there have been good
solutions.

HTH
Paul


Shawn Brown wrote:
> Hi,
>  Can anyone suggest a work around for
> http://code.google.com/p/google-web-toolkit/issues/detail?id=5109
>
> I'll have to look at the src when I get time but this is nuts to me.
>
> Does this work for you?
>
> private String showRequestedMethod(ServletRequest request) throws
> IOException, ServletException {
>   
>   //requestCopy2=(HttpServletRequest) request;
>   
>   //HttpServletRequest requestCopy =(HttpServletRequest) request;
>   
>   String r1 = request.toString();
>   Log.info("request.length" + request.getContentLength());
>   String payload =
> RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));
>   Log.info("payload: "+payload);
>   pay=payload;
>   RPCRequest rpc_request = RPC.decodeRequest(payload);
> //Log.info("rpc. method " + rpc_request.getMethod());
>   Log.info("r.ts "+request.toString());
>   
>   
>   Log.info("request.length" + request.getContentLength());
>   String r2= request.toString();
>   String payload2;
>   try {
>   payload2 = 
> RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));
>   Log.info("payload2: "+payload2);
>   
>   } catch (Exception e) {
>   Log.info("Why the #$% "+ e.getMessage());
>   e.printStackTrace();
>   }
>   Log.info("r.ts2 "+request.toString());
>   
>   Log.info("Are r1 and r2 the same "+r1.equals(r2));
>   
>   return rpc_request.getMethod().toString();
> }
>
> I get an error every time saying "Client did not send 197 bytes as
> expected".  Why it's the same request that is passed into
> RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));
>
> Basically I am checking for authorization in a filter so I need to
> find out what rpc method is being called.  Then if the user has auth,
> I let it go through but then see an error when the method is really
> called.  I call it twice in this method as an example to narrow down
> what is failing.
>
> Any help?  Please!
>
> Shawn
>
> PS. perhaps this is related
> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/9b4a98d0d50d2752
>
>   

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Surely a nasty bug! in RPCServletUtils.readContentAsUtf8

2010-07-13 Thread Shawn Brown
> Search the archives for "Client did not send nn bytes as expected".

OK figured it out.  A HttpServletRequest can be read a total of one time.

Any attempts to use
RPCServletUtils.readContentAsUtf8(((HttpServletRequest) request));
will fail.

The error message is misleading because the client in fact may send that many.

The work around for anyone needing to say use a filter to peek in an
rpc call to see what method will be called or whatever is here
http://forums.sun.com/thread.jspa?forumID=33&threadID=238221

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.