Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCB-1305] CseAsyncRestTemplate is not support set headers #1227

Closed
wants to merge 1 commit into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -84,6 +84,7 @@ public VertxServerRequestToHttpServletRequest(RoutingContext context) {
public void setBodyBuffer(Buffer bodyBuffer) {
super.setBodyBuffer(bodyBuffer);
context.setBody(bodyBuffer);
this.inputStream = null;
}

@Override
Expand Down
Expand Up @@ -112,6 +112,12 @@ public void setRequestBody(Object requestBody) {
this.requestBody = requestBody;
}

public void setHttpHeaders(HttpHeaders headers) {
if (headers != null) {
this.httpHeaders = headers;
}
}

@Override
public HttpMethod getMethod() {
return method;
Expand Down
Expand Up @@ -34,6 +34,7 @@ public void doWithRequest(AsyncClientHttpRequest request) {
CseAsyncClientHttpRequest cseAsyncClientHttpRequest = (CseAsyncClientHttpRequest) request;
if (requestBody != null) {
cseAsyncClientHttpRequest.setRequestBody(requestBody.getBody());
cseAsyncClientHttpRequest.setHttpHeaders(requestBody.getHeaders());
}

if (!CseHttpEntity.class.isInstance(requestBody)) {
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -84,8 +85,10 @@ protected Response doInvoke(Invocation invocation) {
}
};
byte[] body = "abc".getBytes();
HttpHeaders headers = new HttpHeaders();
headers.add("token", "123");
client.setRequestBody(body);

client.setHttpHeaders(headers);
client.execute();

Assert.assertArrayEquals(body, holder.value.getSwaggerArgument(0));
Expand Down