2009-02-12 07:09:29 +01:00
|
|
|
/*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Copyright 2009 Red Hat, Inc.
|
2009-02-12 07:09:29 +01:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Red Hat licenses this file to you under the Apache License, version 2.0
|
|
|
|
* (the "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at:
|
2009-02-12 07:09:29 +01:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-02-12 07:09:29 +01:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2009-02-12 07:09:29 +01:00
|
|
|
*/
|
|
|
|
package org.jboss.netty.handler.codec.http;
|
|
|
|
|
|
|
|
import org.jboss.netty.buffer.ChannelBuffer;
|
|
|
|
|
|
|
|
/**
|
2009-06-19 16:15:20 +02:00
|
|
|
* The default {@link HttpChunk} implementation.
|
|
|
|
*
|
2010-01-26 10:04:19 +01:00
|
|
|
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
|
|
|
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
2009-02-12 07:09:29 +01:00
|
|
|
*/
|
|
|
|
public class DefaultHttpChunk implements HttpChunk {
|
|
|
|
|
2009-11-20 05:12:16 +01:00
|
|
|
private ChannelBuffer content;
|
|
|
|
private boolean last;
|
2009-02-12 07:09:29 +01:00
|
|
|
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* Creates a new instance with the specified chunk content. If an empty
|
2009-06-19 16:49:26 +02:00
|
|
|
* buffer is specified, this chunk becomes the 'end of content' marker.
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2009-02-12 07:09:29 +01:00
|
|
|
public DefaultHttpChunk(ChannelBuffer content) {
|
2009-11-20 05:12:16 +01:00
|
|
|
setContent(content);
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-20 05:12:16 +01:00
|
|
|
public ChannelBuffer getContent() {
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-20 05:12:16 +01:00
|
|
|
public void setContent(ChannelBuffer content) {
|
2009-02-12 07:09:29 +01:00
|
|
|
if (content == null) {
|
|
|
|
throw new NullPointerException("content");
|
|
|
|
}
|
2009-02-12 07:22:06 +01:00
|
|
|
last = !content.readable();
|
2009-02-12 07:09:29 +01:00
|
|
|
this.content = content;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-02-12 07:09:29 +01:00
|
|
|
public boolean isLast() {
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
}
|