spring ClientHttpResponseDecorator 源码

  • 2022-08-08
  • 浏览 (376)

spring ClientHttpResponseDecorator 代码

文件路径:/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java

/*
 * Copyright 2002-2021 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.http.client.reactive;

import reactor.core.publisher.Flux;

import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseCookie;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;

/**
 * Wraps another {@link ClientHttpResponse} and delegates all methods to it.
 * Subclasses can override specific methods selectively.
 *
 * @author Rossen Stoyanchev
 * @since 5.0
 */
public class ClientHttpResponseDecorator implements ClientHttpResponse {

	private final ClientHttpResponse delegate;


	public ClientHttpResponseDecorator(ClientHttpResponse delegate) {
		Assert.notNull(delegate, "Delegate is required");
		this.delegate = delegate;
	}


	public ClientHttpResponse getDelegate() {
		return this.delegate;
	}


	// ClientHttpResponse delegation methods...

	@Override
	public String getId() {
		return this.delegate.getId();
	}

	@Override
	public HttpStatusCode getStatusCode() {
		return this.delegate.getStatusCode();
	}

	@Override
	@Deprecated
	public int getRawStatusCode() {
		return this.delegate.getRawStatusCode();
	}

	@Override
	public HttpHeaders getHeaders() {
		return this.delegate.getHeaders();
	}

	@Override
	public MultiValueMap<String, ResponseCookie> getCookies() {
		return this.delegate.getCookies();
	}

	@Override
	public Flux<DataBuffer> getBody() {
		return this.delegate.getBody();
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + " [delegate=" + getDelegate() + "]";
	}

}

相关信息

spring 源码目录

相关文章

spring AbstractClientHttpRequest 源码

spring ClientHttpConnector 源码

spring ClientHttpRequest 源码

spring ClientHttpRequestDecorator 源码

spring ClientHttpResponse 源码

spring HttpComponentsClientHttpConnector 源码

spring HttpComponentsClientHttpRequest 源码

spring HttpComponentsClientHttpResponse 源码

spring HttpComponentsHeadersAdapter 源码

spring JdkClientHttpConnector 源码

0  赞