Skip to content

Commit 279ec77

Browse files
committed
fix(crawlData): write the correct data to the request body
1 parent 1d18de5 commit 279ec77

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/request.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ function parseHeaders(
6363
function createContentConfig(
6464
rawRequestConfig: LoaderCrawlDataDetail & LoaderCrawlFileDetail
6565
): ContentConfig {
66-
const { data: rawData, url, params, proxyUrl } = rawRequestConfig
66+
const {
67+
data: rawData,
68+
url,
69+
params,
70+
proxyUrl,
71+
timeout,
72+
method
73+
} = rawRequestConfig
6774
const { protocol, hostname, port, pathname, search } = new Url.URL(url)
6875

6976
let path = pathname
@@ -88,9 +95,9 @@ function createContentConfig(
8895
port,
8996
path,
9097

91-
method: rawRequestConfig.method?.toLocaleUpperCase() ?? 'GET',
98+
method: method?.toLocaleUpperCase() ?? 'GET',
9299
headers: {},
93-
timeout: rawRequestConfig.timeout
100+
timeout
94101
},
95102

96103
protocol: protocol as 'http:' | 'https:',
@@ -131,7 +138,7 @@ export function request(config: LoaderCrawlDataDetail & LoaderCrawlFileDetail) {
131138
: https.request(requestConfig, handleRes)
132139

133140
req.on('timeout', () => {
134-
reject(new Error(`Timeout ${config.timeout}ms`))
141+
reject(new Error(`Timeout ${requestConfig.timeout}ms`))
135142
})
136143

137144
req.on('error', (err) => {
@@ -140,7 +147,7 @@ export function request(config: LoaderCrawlDataDetail & LoaderCrawlFileDetail) {
140147

141148
// 其他处理
142149
if (!isUndefined(data)) {
143-
req.write(config.data)
150+
req.write(data)
144151
}
145152

146153
req.end()

0 commit comments

Comments
 (0)