本文整理汇总了Java中org.simpleframework.http.message.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于org.simpleframework.http.message包,在下文中一共展示了Header类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MockEntity
import org.simpleframework.http.message.Header; //导入依赖的package包/类
public MockEntity(Body body, Header header) {
this.body = body;
this.header = header;
}
示例2: getHeader
import org.simpleframework.http.message.Header; //导入依赖的package包/类
public Header getHeader() {
return header;
}
示例3: testPayload
import org.simpleframework.http.message.Header; //导入依赖的package包/类
public void testPayload(int dribble) throws Exception {
Cursor cursor = new DribbleCursor(new StreamCursor(PAYLOAD), 10);
Channel channel = new MockChannel(cursor);
MockSelector selector = new MockSelector();
Collector body = new Collector(new ArrayAllocator(), channel);
long time = System.currentTimeMillis();
while(!selector.isReady()) {
body.collect(selector);
}
System.err.println("Time taken to parse payload "+(System.currentTimeMillis() - time)+" ms");
Header header = body.getHeader();
List<Part> list = body.getBody().getParts();
assertEquals(header.getTarget(), "/index.html");
assertEquals(header.getMethod(), "POST");
assertEquals(header.getMajor(), 1);
assertEquals(header.getMinor(), 0);
assertEquals(header.getContentType().getPrimary(), "multipart");
assertEquals(header.getContentType().getSecondary(), "form-data");
assertEquals(header.getValue("Host"), "some.host.com");
assertEquals(header.getValues("Accept").size(), 4);
assertEquals(header.getValues("Accept").get(0), "image/gif");
assertEquals(header.getValues("Accept").get(1), "image/png");
assertEquals(header.getValues("Accept").get(2), "image/jpeg");
assertEquals(header.getValues("Accept").get(3), "*");
assertEquals(list.size(), 4);
assertEquals(list.get(0).getContentType().getPrimary(), "text");
assertEquals(list.get(0).getContentType().getSecondary(), "plain");
assertEquals(list.get(0).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file1.txt'");
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getContentType().getSecondary(), "plain");
assertEquals(list.get(1).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file2.txt'");
assertEquals(list.get(2).getContentType().getPrimary(), "text");
assertEquals(list.get(2).getContentType().getSecondary(), "plain");
assertEquals(list.get(2).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file3.txt'");
assertEquals(list.get(3).getContentType().getPrimary(), "text");
assertEquals(list.get(3).getContentType().getSecondary(), "plain");
assertEquals(list.get(3).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file4.txt'");
assertEquals(cursor.ready(), -1);
}
示例4: ready
import org.simpleframework.http.message.Header; //导入依赖的package包/类
public void ready(Collector collector) throws IOException {
Entity entity = collector;
Channel channel = entity.getChannel();
Cursor cursor = channel.getCursor();
Header header = entity.getHeader();
Body body = entity.getBody();
List<Part> list = body.getParts();
assertEquals(header.getTarget(), "/index.html");
assertEquals(header.getMethod(), "POST");
assertEquals(header.getMajor(), 1);
assertEquals(header.getMinor(), 0);
assertEquals(header.getContentType().getPrimary(), "multipart");
assertEquals(header.getContentType().getSecondary(), "form-data");
assertEquals(header.getValue("Host"), "some.host.com");
assertEquals(header.getValues("Accept").size(), 4);
assertEquals(header.getValues("Accept").get(0), "image/gif");
assertEquals(header.getValues("Accept").get(1), "image/png");
assertEquals(header.getValues("Accept").get(2), "image/jpeg");
assertEquals(header.getValues("Accept").get(3), "*");
assertEquals(list.size(), 4);
assertEquals(list.get(0).getContentType().getPrimary(), "text");
assertEquals(list.get(0).getContentType().getSecondary(), "plain");
assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
assertEquals(list.get(0).getName(), "pics");
assertEquals(list.get(0).getFileName(), "file1.txt");
assertEquals(list.get(0).isFile(), true);
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getContentType().getSecondary(), "plain");
assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file2.txt\"");
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getName(), "pics");
assertEquals(list.get(1).getFileName(), "file2.txt");
assertEquals(list.get(1).isFile(), true);
assertEquals(list.get(2).getContentType().getSecondary(), "plain");
assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file3.txt\"");
assertEquals(list.get(2).getName(), "pics");
assertEquals(list.get(2).getFileName(), "file3.txt");
assertEquals(list.get(2).isFile(), true);
assertEquals(list.get(3).getContentType().getPrimary(), "text");
assertEquals(list.get(3).getContentType().getSecondary(), "plain");
assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file4.txt\"");
assertEquals(list.get(3).getName(), "pics");
assertEquals(list.get(3).getFileName(), "file4.txt");
assertEquals(list.get(3).isFile(), true);
assertEquals(cursor.ready(), -1);
}
示例5: getHeader
import org.simpleframework.http.message.Header; //导入依赖的package包/类
/**
* This provides the HTTP request header for the entity. This is
* always populated and provides the details sent by the client
* such as the target URI and the query if specified. Also this
* can be used to determine the method and protocol version used.
*
* @return the header provided by the HTTP request message
*/
public Header getHeader() {
return entity.getHeader();
}
示例6: RequestMessage
import org.simpleframework.http.message.Header; //导入依赖的package包/类
/**
* Constructor for the <code>RequestMessage</code> object. This
* is used to create a request with a header instance. In such
* a case the header provided will be queried for headers and is
* used to store headers added to this message instance.
*
* @param header this is the backing header for the message
*/
public RequestMessage(Header header) {
this.header = header;
}
示例7: getHeader
import org.simpleframework.http.message.Header; //导入依赖的package包/类
/**
* This provides the HTTP request header for the entity. This is always
* populated and provides the details sent by the client such as the target
* URI and the query if specified. Also this can be used to determine the
* method and protocol version used.
*
* @return the header provided by the HTTP request message
*/
@Override
public Header getHeader() {
return this.entity.getHeader();
}
示例8: RequestMessage
import org.simpleframework.http.message.Header; //导入依赖的package包/类
/**
* Constructor for the <code>RequestMessage</code> object. This is used to
* create a request with a header instance. In such a case the header
* provided will be queried for headers and is used to store headers added
* to this message instance.
*
* @param header
* this is the backing header for the message
*/
public RequestMessage(Header header) {
this.header = header;
}