Skip to content

Commit

Permalink
CseAsyncRestTemplate is not support set headers
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshenggh committed May 30, 2019
1 parent aafc487 commit 86a4b9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
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

0 comments on commit 86a4b9f

Please sign in to comment.