forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spring-projects#17072 Add default header support to RestTemplateBuilder
- Loading branch information
Showing
10 changed files
with
562 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ain/java/org/springframework/boot/web/client/AbstractHttpHeadersDefaultingCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2012-2019 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.web.client; | ||
|
||
import org.springframework.http.HttpHeaders; | ||
|
||
/** | ||
* {@link HttpHeadersCustomizer} that only adds headers that were not populated in the | ||
* request. | ||
* | ||
* @author Ilya Lukyanovich | ||
*/ | ||
public abstract class AbstractHttpHeadersDefaultingCustomizer implements HttpHeadersCustomizer { | ||
|
||
@Override | ||
public void applyTo(HttpHeaders headers) { | ||
createHeaders().forEach((key, value) -> headers.merge(key, value, (oldValue, ignored) -> oldValue)); | ||
} | ||
|
||
protected abstract HttpHeaders createHeaders(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
.../spring-boot/src/main/java/org/springframework/boot/web/client/HttpHeadersCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2012-2019 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.web.client; | ||
|
||
import org.springframework.http.HttpHeaders; | ||
|
||
/** | ||
* Callback interface that can be used to customize a {@link HttpHeaders}. | ||
* | ||
* @author Ilya Lukyanovich | ||
* @see HttpHeadersCustomizingClientHttpRequestFactory | ||
*/ | ||
@FunctionalInterface | ||
public interface HttpHeadersCustomizer { | ||
|
||
/** | ||
* Callback to customize a {@link HttpHeaders} instance. | ||
* @param headers the headers to customize | ||
*/ | ||
void applyTo(HttpHeaders headers); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.