项目要求把http请求和响应的报文输出
发送http采用的是restlet框架 其中报文body用Representation类坐了封装
通过方法
Representation.getText();
可以获取到报文body
但开发中遇到不能重复执行getText()的问题
通过查源码得知:在http响应时Representation封装了一个io流 只能读取一次
好在Representation提供了isTransient()方法来判断getText()能否重复执行
/**
* Indicates if the representation's content is transient, which means that
* it can be obtained only once. This is often the case with representations
* transmitted via network sockets for example. In such case, if you need to
* read the content several times, you need to cache it first, for example
* into memory or into a file.
*
* @return True if the representation's content is transient.
*/
public boolean isTransient() {
return this.isTransient;
}
分享到:
相关推荐
restlet相关文档
org.restlet.jar
Restlet与Spring 集成
restlet项目
一个简单的Restlet开发框架的Basic认证的例子
Restlet Client插件是一款运行在chrome内核浏览器上的Web服务测试插件,该插件主要用于测试各种Web服务,能查看网站基本信息、浏览网页代码并能发送HTTP请求来测试网站Web服务,同时支持自动化API场景。用户在安装了...
Restlet API包括一些能够创建基于字符串、文件、流(stream)、通道(channel)及XML文档的表示(representation),它支持SAX、DOM及XSLT。使用FreeMaker或Apache Velocity模板引擎,你可以很容易地创建基于JSP式...
Restlet所需要的所有jar包 一次下载,以后高枕无忧!
restlet2.1学习笔记项目代码
RESTLET开发实例(二)使用Component、Application的REST服务
restlet入门helloworld示例
本文是对Restlet官方教程http://restlet.com/learn/tutorial/2.2/的中文翻译。
Restlet2.0用户指南
RESTLET框架学习书籍
Restlet API包括一些能够创建基于字符串、文件、流(stream)、通道(channel)及XML文档的表示(representation),它支持SAX、DOM及XSLT。使用FreeMaker或Apache Velocity模板引擎,你可以很容易地创建基于JSP式...
Restlet Client 插件是一个类似Postman的Api接口测试工具, 界面友好, UI布局也更合理。相比Postman, Restlet Client无需安装本地客户端, 即装即用, 占用空间小, 功能强大。
restlet restful,web工程,可直接运行。启动后,main方法作为client运行调用服务端。服务器数据之间沟通利器,绝对不坑。
资源里面包含了Restlet从入门到高级的开发过程,对学习Restlet有很大的帮助
restlet工程示例,restlet工程小例子