File tree 5 files changed +17
-13
lines changed
spring-web/src/main/java/org/springframework/http 5 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2010 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
* Represents an HTTP input message, consisting of {@linkplain #getHeaders() headers}
24
24
* and a readable {@linkplain #getBody() body}.
25
25
*
26
- * <p>Typically implemented by an HTTP request on the server-side, or a response on the client-side.
26
+ * <p>Typically implemented by an HTTP request handle on the server side,
27
+ * or an HTTP response handle on the client side.
27
28
*
28
29
* @author Arjen Poutsma
29
30
* @since 3.0
@@ -32,7 +33,7 @@ public interface HttpInputMessage extends HttpMessage {
32
33
33
34
/**
34
35
* Return the body of the message as an input stream.
35
- * @return the input stream body
36
+ * @return the input stream body (never {@code null})
36
37
* @throws IOException in case of I/O Errors
37
38
*/
38
39
InputStream getBody () throws IOException ;
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2009 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package org .springframework .http ;
18
18
19
19
/**
20
- * Represents the base interface for HTTP request and response messages. Consists of {@link HttpHeaders}, retrievable
21
- * via {@link #getHeaders()}.
20
+ * Represents the base interface for HTTP request and response messages.
21
+ * Consists of {@link HttpHeaders}, retrievable via {@link #getHeaders()}.
22
22
*
23
23
* @author Arjen Poutsma
24
24
* @since 3.0
@@ -27,7 +27,7 @@ public interface HttpMessage {
27
27
28
28
/**
29
29
* Return the headers of this message.
30
- * @return a corresponding HttpHeaders object
30
+ * @return a corresponding HttpHeaders object (never {@code null})
31
31
*/
32
32
HttpHeaders getHeaders ();
33
33
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2010 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
* Represents an HTTP output message, consisting of {@linkplain #getHeaders() headers}
24
24
* and a writable {@linkplain #getBody() body}.
25
25
*
26
- * <p>Typically implemented by an HTTP request on the client-side, or a response on the server-side.
26
+ * <p>Typically implemented by an HTTP request handle on the client side,
27
+ * or an HTTP response handle on the server side.
27
28
*
28
29
* @author Arjen Poutsma
29
30
* @since 3.0
@@ -32,7 +33,7 @@ public interface HttpOutputMessage extends HttpMessage {
32
33
33
34
/**
34
35
* Return the body of the message as an output stream.
35
- * @return the output stream body
36
+ * @return the output stream body (never {@code null})
36
37
* @throws IOException in case of I/O Errors
37
38
*/
38
39
OutputStream getBody () throws IOException ;
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2014 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
24
24
import org .apache .http .HttpResponse ;
25
25
26
26
import org .springframework .http .HttpHeaders ;
27
+ import org .springframework .util .StreamUtils ;
27
28
28
29
/**
29
30
* {@link ClientHttpResponse} implementation that uses
@@ -72,7 +73,7 @@ public HttpHeaders getHeaders() {
72
73
@ Override
73
74
public InputStream getBody () throws IOException {
74
75
HttpEntity entity = this .httpResponse .getEntity ();
75
- return entity != null ? entity .getContent () : null ;
76
+ return ( entity != null ? entity .getContent () : StreamUtils . emptyInput ()) ;
76
77
}
77
78
78
79
@ Override
Original file line number Diff line number Diff line change 26
26
import org .apache .http .util .EntityUtils ;
27
27
28
28
import org .springframework .http .HttpHeaders ;
29
+ import org .springframework .util .StreamUtils ;
29
30
30
31
/**
31
32
* {@link org.springframework.http.client.ClientHttpResponse} implementation that uses
@@ -76,7 +77,7 @@ public HttpHeaders getHeaders() {
76
77
@ Override
77
78
public InputStream getBody () throws IOException {
78
79
HttpEntity entity = this .httpResponse .getEntity ();
79
- return (entity != null ? entity .getContent () : null );
80
+ return (entity != null ? entity .getContent () : StreamUtils . emptyInput () );
80
81
}
81
82
82
83
@ Override
You can’t perform that action at this time.
0 commit comments