Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>


<!-- HttpClient -->
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty-http</artifactId>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.alibaba.cloud.ai.copilot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;
import reactor.netty.http.HttpProtocol;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;

/**
* 目的: 强制使用 HTTP/1.1
*/
@Configuration
public class WebClientConfig {

@Bean
public WebClient webClient() {
// 创建并直接配置 HttpClient
HttpClient httpClient = HttpClient.create()
.protocol(HttpProtocol.HTTP11); // 强制使用 HTTP/1.1

return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient)) // 集成配置
.build();
}
}