提交 ab654a7a 编写于 作者: A Arjen Poutsma

added toString to HttpEntity

上级 5206f5bc
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -122,4 +122,19 @@ public class HttpEntity<T> {
return (this.body != null);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("<");
if (body != null) {
builder.append(body);
if (headers != null) {
builder.append(',');
}
}
if (headers != null) {
builder.append(headers);
}
builder.append('>');
return builder.toString();
}
}
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -93,4 +93,27 @@ public class ResponseEntity<T> extends HttpEntity<T> {
public HttpStatus getStatusCode() {
return statusCode;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("<");
builder.append(statusCode.toString());
builder.append(' ');
builder.append(statusCode.getReasonPhrase());
builder.append(',');
T body = getBody();
HttpHeaders headers = getHeaders();
if (body != null) {
builder.append(body);
if (headers != null) {
builder.append(',');
}
}
if (headers != null) {
builder.append(headers);
}
builder.append('>');
return builder.toString();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册