Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wd1105040417
retrofit
提交
f1534a96
R
retrofit
项目概览
wd1105040417
/
retrofit
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
retrofit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1534a96
编写于
8月 16, 2012
作者:
E
Eric Denman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Associate log messages with the request that caused them
上级
9ada4bfd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
8 deletion
+13
-8
http/src/main/java/retrofit/http/CallbackResponseHandler.java
.../src/main/java/retrofit/http/CallbackResponseHandler.java
+12
-7
http/src/main/java/retrofit/http/GsonResponseHandler.java
http/src/main/java/retrofit/http/GsonResponseHandler.java
+1
-1
未找到文件。
http/src/main/java/retrofit/http/CallbackResponseHandler.java
浏览文件 @
f1534a96
...
...
@@ -25,12 +25,17 @@ public abstract class CallbackResponseHandler<T>
Logger
.
getLogger
(
CallbackResponseHandler
.
class
.
getName
());
private
final
Callback
<
T
>
callback
;
private
final
Gson
gson
;
private
String
requestUrl
;
// Can be null.
protected
CallbackResponseHandler
(
Gson
gson
,
Callback
<
T
>
callback
)
{
this
(
gson
,
callback
,
null
);
}
protected
CallbackResponseHandler
(
Gson
gson
,
Callback
<
T
>
callback
,
String
requestUrl
)
{
this
.
gson
=
gson
;
this
.
callback
=
callback
;
this
.
requestUrl
=
requestUrl
;
}
/**
...
...
@@ -61,7 +66,7 @@ public abstract class CallbackResponseHandler<T>
int
statusCode
=
statusLine
.
getStatusCode
();
if
(
statusCode
==
HttpStatus
.
SC_UNAUTHORIZED
)
{
LOGGER
.
fine
(
"Session expired.
"
);
LOGGER
.
fine
(
"Session expired.
Request url "
+
requestUrl
);
callback
.
sessionExpired
();
return
null
;
}
...
...
@@ -71,7 +76,7 @@ public abstract class CallbackResponseHandler<T>
// 2XX == successful request
if
(
statusCode
>=
200
&&
statusCode
<
300
)
{
if
(
entity
==
null
)
{
LOGGER
.
fine
(
"Missing entity for "
+
statusCode
+
" response.
"
);
LOGGER
.
fine
(
"Missing entity for "
+
statusCode
+
" response.
Url "
+
requestUrl
);
callback
.
serverError
(
null
,
statusCode
);
return
null
;
}
...
...
@@ -91,11 +96,11 @@ public abstract class CallbackResponseHandler<T>
// TODO: Use specified encoding.
String
body
=
new
String
(
HttpClients
.
entityToBytes
(
entity
),
"UTF-8"
);
LOGGER
.
fine
(
"Server returned "
+
statusCode
+
", "
+
statusLine
.
getReasonPhrase
()
+
". Body: "
+
body
);
+
statusLine
.
getReasonPhrase
()
+
". Body: "
+
body
+
". Request url "
+
requestUrl
);
callback
.
serverError
(
parseServerMessage
(
statusCode
,
body
),
statusCode
);
}
else
{
LOGGER
.
fine
(
"Server returned "
+
statusCode
+
", "
+
statusLine
.
getReasonPhrase
()
+
".
"
);
+
statusLine
.
getReasonPhrase
()
+
".
Request url "
+
requestUrl
);
callback
.
serverError
(
null
,
statusCode
);
}
return
null
;
...
...
@@ -109,7 +114,7 @@ public abstract class CallbackResponseHandler<T>
String
body
=
new
String
(
HttpClients
.
entityToBytes
(
bufferedEntity
),
"UTF-8"
);
LOGGER
.
fine
(
"Server returned "
+
statusCode
+
", "
+
statusLine
.
getReasonPhrase
()
+
". Body: "
+
body
);
+
statusLine
.
getReasonPhrase
()
+
". Body: "
+
body
+
". Request url "
+
requestUrl
);
try
{
callback
.
clientError
(
parse
(
bufferedEntity
),
statusCode
);
}
catch
(
ServerException
e
)
{
...
...
@@ -118,7 +123,7 @@ public abstract class CallbackResponseHandler<T>
}
}
else
{
LOGGER
.
fine
(
"Server returned "
+
statusCode
+
", "
+
statusLine
.
getReasonPhrase
()
+
".
"
);
+
statusLine
.
getReasonPhrase
()
+
".
Request url "
+
requestUrl
);
callback
.
clientError
(
null
,
statusCode
);
}
return
null
;
...
...
http/src/main/java/retrofit/http/GsonResponseHandler.java
浏览文件 @
f1534a96
...
...
@@ -28,7 +28,7 @@ class GsonResponseHandler<T> extends CallbackResponseHandler<T> {
private
GsonResponseHandler
(
Gson
gson
,
Type
type
,
Callback
<
T
>
callback
,
String
url
,
Date
start
,
ThreadLocal
<
SimpleDateFormat
>
dateFormat
)
{
super
(
gson
,
callback
);
super
(
gson
,
callback
,
url
);
this
.
gson
=
gson
;
this
.
type
=
type
;
this
.
url
=
url
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录