2009-11-17 06:27:20 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.handler.codec.http;
|
2009-11-17 06:27:20 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2011-12-09 04:38:59 +01:00
|
|
|
import io.netty.buffer.ChannelBuffer;
|
|
|
|
import io.netty.buffer.ChannelBuffers;
|
2009-11-17 06:27:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The default {@link HttpChunkTrailer} implementation.
|
|
|
|
*/
|
|
|
|
public class DefaultHttpChunkTrailer implements HttpChunkTrailer {
|
|
|
|
|
2010-01-08 09:29:37 +01:00
|
|
|
private final HttpHeaders headers = new HttpHeaders() {
|
|
|
|
@Override
|
|
|
|
void validateHeaderName(String name) {
|
|
|
|
super.validateHeaderName(name);
|
|
|
|
if (name.equalsIgnoreCase(HttpHeaders.Names.CONTENT_LENGTH) ||
|
|
|
|
name.equalsIgnoreCase(HttpHeaders.Names.TRANSFER_ENCODING) ||
|
|
|
|
name.equalsIgnoreCase(HttpHeaders.Names.TRAILER)) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"prohibited trailing header: " + name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2009-11-17 06:27:20 +01:00
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public boolean isLast() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2010-01-26 05:31:54 +01:00
|
|
|
public void addHeader(final String name, final Object value) {
|
2010-01-08 09:29:37 +01:00
|
|
|
headers.addHeader(name, value);
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2010-01-26 05:31:54 +01:00
|
|
|
public void setHeader(final String name, final Object value) {
|
2010-01-08 09:29:37 +01:00
|
|
|
headers.setHeader(name, value);
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2010-01-26 05:31:54 +01:00
|
|
|
public void setHeader(final String name, final Iterable<?> values) {
|
2010-01-08 09:29:37 +01:00
|
|
|
headers.setHeader(name, values);
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public void removeHeader(final String name) {
|
2010-01-08 09:29:37 +01:00
|
|
|
headers.removeHeader(name);
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public void clearHeaders() {
|
2010-01-08 09:29:37 +01:00
|
|
|
headers.clearHeaders();
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public String getHeader(final String name) {
|
2010-01-08 09:29:37 +01:00
|
|
|
return headers.getHeader(name);
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public List<String> getHeaders(final String name) {
|
2010-01-08 09:29:37 +01:00
|
|
|
return headers.getHeaders(name);
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2010-01-08 09:29:37 +01:00
|
|
|
public List<Map.Entry<String, String>> getHeaders() {
|
|
|
|
return headers.getHeaders();
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public boolean containsHeader(final String name) {
|
2010-01-08 09:29:37 +01:00
|
|
|
return headers.containsHeader(name);
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public Set<String> getHeaderNames() {
|
2010-01-08 09:29:37 +01:00
|
|
|
return headers.getHeaderNames();
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-17 06:27:20 +01:00
|
|
|
public ChannelBuffer getContent() {
|
|
|
|
return ChannelBuffers.EMPTY_BUFFER;
|
|
|
|
}
|
2009-11-20 05:12:16 +01:00
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2009-11-20 05:12:16 +01:00
|
|
|
public void setContent(ChannelBuffer content) {
|
|
|
|
throw new IllegalStateException("read-only");
|
|
|
|
}
|
2009-11-17 06:27:20 +01:00
|
|
|
}
|