{"id":267844,"date":"2023-04-12T09:00:56","date_gmt":"2023-04-12T01:00:56","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=267844"},"modified":"2023-03-29T09:33:13","modified_gmt":"2023-03-29T01:33:13","slug":"fvfb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/fvfb.html","title":{"rendered":"Forest v1.5.30 \u53d1\u5e03"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nForest v1.5.30 \u53d1\u5e03\uff0c\u9002\u914d SpringBoot3 \u548c Solon\uff0c\u65b0\u589e\u5ef6\u8fdf\u53c2\u6570<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

Forest \u4ecb\u7ecd<\/strong><\/div>\n

Forest \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 Java HTTP \u5ba2\u6237\u7aef\u6846\u67b6\uff0c\u5b83\u80fd\u591f\u5c06 HTTP \u7684\u6240\u6709\u8bf7\u6c42\u4fe1\u606f\uff08\u5305\u62ec URL\u3001Header \u4ee5\u53ca Body \u7b49\u4fe1\u606f\uff09\u7ed1\u5b9a\u5230\u60a8\u81ea\u5b9a\u4e49\u7684 Interface \u65b9\u6cd5\u4e0a\uff0c\u80fd\u591f\u901a\u8fc7\u8c03\u7528\u672c\u5730\u63a5\u53e3\u65b9\u6cd5\u7684\u65b9\u5f0f\u53d1\u9001 HTTP \u8bf7\u6c42<\/p>\n

\u83b7\u5f97\u5956\u9879<\/strong><\/div>\n

2021 \u5e74\u5ea6 OSC \u4e2d\u56fd\u5f00\u6e90\u9879\u76ee\u8bc4\u9009\u300c\u6700\u53d7\u6b22\u8fce\u9879\u76ee\u300d<\/p>\n

2022 \u5e74\u5ea6 OSC \u4e2d\u56fd\u5f00\u6e90\u9879\u76ee\u8bc4\u9009\u300c\u6700\u706b\u70ed\u4e2d\u56fd\u5f00\u6e90\u9879\u76ee\u793e\u533a\u300d<\/p>\n

\u7b80\u5355\u7684\u6817\u5b50<\/strong><\/div>\n
\u58f0\u660e\u5f0f\u63a5\u53e3<\/strong><\/span><\/div>\n

\u521b\u5efa\u4e00\u4e2a interface\uff0c\u5e76\u7528 @Get \u6ce8\u89e3\u4fee\u9970\u63a5\u53e3\u65b9\u6cd5\u3002<\/p>\n

public interface MyClient {\r\n    @Get(\"http:\/\/localhost:8080\/hello\")\r\n    String hello();\r\n}<\/pre>\n

\u901a\u8fc7 @Get \u6ce8\u89e3\uff0c\u5c06\u4e0a\u9762\u7684 MyClient \u63a5\u53e3\u4e2d\u7684 simpleRequest() \u65b9\u6cd5\u7ed1\u5b9a\u4e86\u4e00\u4e2a HTTP \u8bf7\u6c42\uff0c \u5176 URL \u4e3a http:\/\/localhost:8080\/hello\uff0c\u5e76\u9ed8\u8ba4\u4f7f\u7528 GET \u65b9\u5f0f\uff0c\u4e14\u5c06\u8bf7\u6c42\u54cd\u5e94\u7684\u6570\u636e\u4ee5 String \u7684\u65b9\u5f0f\u8fd4\u56de\u7ed9\u8c03\u7528\u8005<\/p>\n

\u7f16\u7a0b\u5f0f\u63a5\u53e3<\/strong><\/span><\/div>\n
Forest.get(\"http:\/\/localhost:8080\/hello\").execute();<\/pre>\n

\u7f16\u7a0b\u5f0f\u63a5\u53e3\u5219\u66f4\u4e3a\u7b80\u5355\u76f4\u63a5<\/p>\n

\u65b0\u589e\u7279\u6027<\/strong><\/div>\n

\u652f\u6301\u548c\u9002\u914d\u4e86 SpringBoot3<\/p>\n

\u652f\u6301\u548c\u9002\u914d\u4e86 Solon \u6846\u67b6<\/p>\n

\u652f\u6301\u5ef6\u8fdf\u53c2\u6570\u7279\u6027<\/p>\n

\u5ef6\u8fdf\u53c2\u6570 (Lambda \u53c2\u6570)<\/strong><\/div>\n

\u6709\u5f88\u591a\u60c5\u51b5\uff0cHeader\u3001Query\u3001Body \u7684\u53c2\u6570\u503c\u4e0d\u80fd\u9a6c\u4e0a\u5f97\u51fa\uff0c\u800c\u662f\u5728\u8bf7\u6c42\u53d1\u9001\u524d\u7684\u90a3\u4e00\u523b\uff08\u6240\u6709\u8bf7\u6c42\u53c2\u6570\u90fd\u5230\u4f4d\u65f6\uff09\u624d\u80fd\u5f97\u51fa\uff0c\u5178\u578b\u7684\u4f8b\u5b50\u5c31\u662f\u52a0\u7b7e\u9a8c\u8bc1\u7684\u573a\u666f\uff08\u5728 Header \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u53c2\u6570 token\uff0c\u800c token \u7684\u503c\u662f\u5bf9\u6574\u4e2a body \u505a\u52a0\u5bc6\u7684\u7ed3\u679c\uff09<\/p>\n

\u8bf7\u6c42\u5934\u7684\u5ef6\u8fdf\u53c2\u6570<\/p>\n

Forest.post(\"\/test\")\r\n        .addHeader(\"Content-Type\", \"application\/json; charset=UTF-8\")          \/\/ \u666e\u901a\u8bf7\u6c42\u5934\r\n        .addHeader(\"Authorization\", req -> Base64.encode(req.body().encode())) \/\/ \u5ef6\u8fdf\u8bf7\u6c42\u5934\r\n        .addBody(\"id\", \"1972664191\")      \/\/ \u8bf7\u6c42\u4f53\u53c2\u6570 id\r\n        .addBody(\"name\", \"XieYu20011008\") \/\/ \u8bf7\u6c42\u4f53\u53c2\u6570 name\r\n        .execute();<\/pre>\n

\u8bf7\u6c42\u4f53\u7684\u5ef6\u8fdf\u53c2\u6570<\/p>\n

Forest.post(\"\/test\")\r\n        .addHeader(\"Content-Type\", \"application\/json; charset=UTF-8\")  \/\/ \u8bf7\u6c42\u5934\r\n        .addHeader(\"_id\", \"20011008\")                                  \/\/ \u8bf7\u6c42\u5934\r\n        .addBody(\"id\", \"1972664191\")                                   \/\/ \u8bf7\u6c42\u4f53\u53c2\u6570 id\r\n        .addBody(\"name\", req -> \"Foo\" + req.headerValue(\"_id\"))        \/\/ \u5ef6\u8fdf\u8bf7\u6c42\u4f53\u53c2\u6570 name\r\n        .addBody(\"token\", req -> Base64.encode(req.body().encode()))   \/\/ \u5ef6\u8fdf\u8bf7\u6c42\u4f53\u53c2\u6570 token\r\n        .execute();                                                    \/\/ \u6267\u884c\u8bf7\u6c42\r\n<\/pre>\n
\u5b98\u7f51\u548c\u4ed3\u5e93\u5730\u5740<\/strong><\/div>\n

\u5b98\u7f51\u5730\u5740:
\nhttp:\/\/forest.dtflyx.com<\/p>\n

Gitee \u4ed3\u5e93\u5730\u5740:
\nhttps:\/\/gitee.com\/dromara\/forest<\/p>\n

Github \u4ed3\u5e93\u5730\u5740:
\nhttps:\/\/github.com\/dromara\/forest<\/p>\n

\u672c\u6b21\u66f4\u65b0\u5185\u5bb9<\/strong><\/div>\n
  • feat: \u9002\u914d springboot3<\/li>\n
  • feat: \u9002\u914d solon<\/li>\n
  • feat: \u5ef6\u8fdf\u53c2\u6570 (Lambda \u53c2\u6570)\uff0c\u652f\u6301 Query, Header\uff0cBody \u4e09\u79cd\u53c2\u6570\u7684\u5ef6\u8fdf\u6c42\u503c<\/li>\n
  • feat: \u53ef\u81ea\u5b9a\u4e49\u5f02\u6b65\u8bf7\u6c42\u6c60\u62d2\u7edd\u7b56\u7565<\/li>\n
  • feat: \u8bf7\u6c42\u4f53\u5e8f\u5217\u5316\u63a5\u53e3\uff0cForestRequest.body ().encode () \u548c ForestRequest.body ().encodeToString ()<\/li>\n
  • fix: ForestProxy \u6dfb\u52a0 header \u6ca1\u6709\u6548\u679c<\/li>\n
  • fix: onBodyEncode \u751f\u547d\u5468\u671f\u987a\u5e8f\u95ee\u9898<\/li>\n
  • fix: \u4e0d\u540c ForestConfiguration \u5bf9\u8c61\u5171\u7528\u540c\u4e00\u4e2a\u5f02\u6b65\u7ebf\u7a0b\u6c60\u7684\u95ee\u9898<\/li>\n
  • fix: \u65e0\u6cd5\u89e3\u6790 localhost:8080 \u8fd9\u7c7b\u7701\u7565 http:\/\/ \u7684 url<\/li>\n
  • reflector: \u5c06 xml \u89e3\u6790\u6a21\u5757\u62c6\u5206\u6210\u4e86 forest-jaxb \u548c forest-jakarta-xml \u4e24\u4e2a\u5b50\u6a21\u5757\uff0c\u9700\u8981\u7684\u60c5\u51b5\u8981\u5206\u522b\u81ea\u884c\u5f15\u5165<\/li>\n
  • reflector: request body encoder<\/li>\n
  • refactor: Forest Body clone<\/li>\n
  • refactor: \u6784\u5efa Query String \u90e8\u5206<\/li>\n
  • add: HTTPRoxy \u6ce8\u89e3\u7684 headers \u5c5e\u6027<\/li>\n
  • add: forest \u793a\u4f8b\u5de5\u7a0b<\/li>\n","protected":false},"excerpt":{"rendered":"

    Forest \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 Java HTTP \u5ba2\u6237\u7aef\u6846\u67b6\uff0c\u5b83\u80fd\u591f\u5c06 HTTP \u7684\u6240\u6709\u8bf7\u6c42\u4fe1\u606f\uff08\u5305\u62ec URL\u3001 […]<\/p>\n","protected":false},"author":1920,"featured_media":208819,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-267844","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1920"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=267844"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267844\/revisions"}],"predecessor-version":[{"id":268400,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267844\/revisions\/268400"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/208819"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=267844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=267844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=267844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}