使用requestjs,我发送一个POST多部分/表单数据请求,如下所示;
request.post({
uri: "https://app.bom.com/items/command-export-2",
headers: {
"cookies": cookie,
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryS4isRj4WDxhi155d"
},
formData: {
wfs_id: "17767554",
search_category: "item_number",
search_textfield: "161337",
kept_items_p: "0",
kept_objects_list: "",
search_mode: "adv",
query_id: queryId,
list_export_p: "1",
all_objects_p: "0",
item_count: itemCount,
show_only_checked_p: "0",
import_id: "0",
import_list_p: "0",
tabular_format_option: "",
form_file_format: "0",
csv_setting_id: "-20000",
pdx_setting_id: "0",
export_now_btn: "Export Now »"
},
jar: jar
})
.on('response', function(response) {
log.info(response);
log.info(jar);
})
.on('error', _error);我得到了302代码的答复。我认为requestjs默认支持重定向。这是预期的行为吗?
发布于 2015-08-13 17:30:45
默认情况下,请求只遵循GET重定向请求。由于您使用的是POST请求,请使用
followAllRedirects: true遵循来自POST请求的重定向。
followAllRedirects -遵循非获取HTTP3xx响应作为重定向(默认值: false)
https://stackoverflow.com/questions/31994804
复制相似问题