mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
4.0.3
This commit is contained in:
@@ -22,9 +22,11 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -135,6 +137,19 @@ public class Example1001_BaseController {
|
|||||||
return testResult;
|
return testResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取header
|
||||||
|
@Open(value = "test.head",version = "1.0")
|
||||||
|
@GetMapping("/get/header/v1")
|
||||||
|
public StoryResult header(@RequestBody StoryParam story, HttpServletRequest request) {
|
||||||
|
HttpServletRequest servletRequest = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
|
StoryResult storyResult = new StoryResult();
|
||||||
|
storyResult.setId(1L);
|
||||||
|
storyResult.setName(story.getName()
|
||||||
|
+ ", token1:" + request.getHeader("token")
|
||||||
|
+ ", token2:" + servletRequest.getHeader("token"));
|
||||||
|
return storyResult;
|
||||||
|
}
|
||||||
|
|
||||||
// 返回数组结果
|
// 返回数组结果
|
||||||
@ApiOperation(value = "返回数组结果(第二)", notes = "返回数组结果", position = -99)
|
@ApiOperation(value = "返回数组结果(第二)", notes = "返回数组结果", position = -99)
|
||||||
@Open("story.list")
|
@Open("story.list")
|
||||||
|
@@ -218,6 +218,22 @@ public class AllInOneTest extends TestBase {
|
|||||||
client.execute(requestBuilder);
|
client.execute(requestBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传递header
|
||||||
|
*/
|
||||||
|
public void testHeader() {
|
||||||
|
Map<String, String> header = new HashMap<>(8);
|
||||||
|
header.put("token", "aaaabbbb");
|
||||||
|
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
|
||||||
|
.method("test.head")
|
||||||
|
.version("1.0")
|
||||||
|
.header(header)
|
||||||
|
.bizContent(new BizContent().add("id", "1").add("name", "葫芦娃"))
|
||||||
|
.httpMethod(HttpTool.HTTPMethod.GET);
|
||||||
|
|
||||||
|
client.execute(requestBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试post提交大文本内容
|
* 测试post提交大文本内容
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
Reference in New Issue
Block a user