Skip to content

Commit

Permalink
修复表单请求时的请求头处理 (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan authored Apr 10, 2024
1 parent 1b621a3 commit 9a2add6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 2 additions & 3 deletions httpfpt/schemas/case_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

from typing import TYPE_CHECKING, Any
from typing import Any

from pydantic import AnyHttpUrl, BaseModel, ConfigDict, Field
from typing_extensions import Literal

if TYPE_CHECKING:
from httpfpt.enums.query_fetch_type import QueryFetchType
from httpfpt.enums.query_fetch_type import QueryFetchType # noqa: TCH001

__all__ = [
'CaseData',
Expand Down
8 changes: 2 additions & 6 deletions httpfpt/utils/request/request_data_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,11 @@ def get_request_data_parsed(self, relate_log: bool = False) -> dict:
headers = self.headers
body_type = self.body_type
body = self.body
files = self.files
if not headers:
if body_type:
headers = {}
if body_type == BodyType.form_data:
if files is not None:
pass # 如果包含上传文件操作,则由引擎自动处理
else:
headers.update({'Content-Type': 'multipart/form-data'})
pass # 表单请求由引擎自动处理
elif body_type == BodyType.x_www_form_urlencoded:
headers.update({'Content-Type': 'application/x-www-form-urlencoded'})
elif body_type == BodyType.binary:
Expand Down Expand Up @@ -754,7 +750,7 @@ def get_request_data_parsed(self, relate_log: bool = False) -> dict:
'cookies': self.cookies,
'body_type': body_type,
'body': body,
'files': files,
'files': self.files,
'files_no_parse': self.files_no_parse,
'is_setup': self.is_setup,
'setup': self.setup,
Expand Down

0 comments on commit 9a2add6

Please sign in to comment.