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

【1.9.0】http 插件支持 json 转义 #40 #46

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -24,6 +24,7 @@
import traceback
from copy import deepcopy

import ujson as json
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from pipeline.component_framework.component import Component
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
Loading