Skip to content

Commit

Permalink
feat: http 插件支持 json 转义 TencentBlueKing#40
Browse files Browse the repository at this point in the history
  • Loading branch information
guohelu committed Oct 25, 2024
1 parent 148617a commit ba717f6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions bkflow/pipeline_plugins/components/collections/http/v1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from __future__ import absolute_import

import json
import traceback
from copy import deepcopy

Expand Down Expand Up @@ -93,10 +94,7 @@ def inputs_format(self):
key="bk_http_success_exp",
type="string",
schema=StringItemSchema(
description=_(
"根据返回的 JSON 的数据来控制节点的成功或失败, "
"使用 resp 引用返回的 JSON 对象,例 resp.result==True"
)
description=_("根据返回的 JSON 的数据来控制节点的成功或失败, " "使用 resp 引用返回的 JSON 对象,例 resp.result==True")
),
),
]
Expand Down Expand Up @@ -133,6 +131,8 @@ def plugin_schedule(self, data, parent_data, callback_data=None):
other = {"headers": {}, "timeout": timeout}

if method.upper() not in ["GET", "HEAD"]:
if not isinstance(body, str):
body = json.dumps(body)
other["data"] = body.encode("utf-8")
other["headers"] = {"Content-type": "application/json"}

Expand Down Expand Up @@ -195,10 +195,7 @@ def __getstate__(self):

class HttpComponent(Component):
name = _("HTTP 请求")
desc = _(
"提示: 1.请求URL需要在当前网络下可以访问,否则会超时失败 "
"2.响应状态码在200-300(不包括300)之间,并且响应内容是 JSON 格式才会执行成功"
)
desc = _("提示: 1.请求URL需要在当前网络下可以访问,否则会超时失败 " "2.响应状态码在200-300(不包括300)之间,并且响应内容是 JSON 格式才会执行成功")
code = "bk_http_request"
bound_service = HttpRequestService
version = "v1.0"
Expand Down

0 comments on commit ba717f6

Please sign in to comment.