Hi John,

if you want to create the entity as String, you have to read the String. 
But if it is read, the data is read ... and no available in the Stream 
anymore.

best regards
   Stephan

John Prystash schrieb:
> Hey Everyone, I encountered this behavior and was wondering if it is 
> intentional.  I'm sure it is, but if so I was wondering about the 
> reasoning behind it.
>
> In my Guard override, during authorize() I need to inspect the body of 
> the request:
>
>     @Override
>   public boolean authorize(Request request) {
>      ...
>      String text= request.getEntity().getText();
>      ...
>   }
>
>
> When I get the Resource method, the body is null:
>
>     @Override
>   public void post(Representation entity) {
>       ...
>       String text = entity.getText(); // is null
>             ...
>   }
>
> From InputRepresentation:
>
>     @Override
>     public InputStream getStream() throws IOException {
>      final InputStream result = this.stream;
>      setStream(null);
>      return result;
>   }
>
>   @Override
>   public String getText() throws IOException {
>       return ByteUtils.toString(getStream(), getCharacterSet());
>   }
>
> I was wondering if the setStream(null) is intended behavior (or if I'm 
> abusing the purpose of the Guard) and if so, some background for my 
> education would be much appreciated.  Thanks!
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1140979

Reply via email to