NodeJS와 응답 헤더에서-쿠키를 설정 가져올 수 없습니다 HTTP 노드 라이브러리내가 3 개의 differents을 시도
- 노드 요청
- 노드
- 노드 바늘
모든 requestify 3 라이브러리 중 내 응답에서 내 쿠키를 가져올 수 없습니다.
요청
15:32:52 - WARN - now testing with request
{ 'x-powered-by': 'Express',
'content-type': 'application/json; charset=utf-8',
'content-length': '4591',
date: 'Thu, 11 Dec 2014 14:32:52 GMT',
connection: 'keep-alive' }
니들
15:32:52 - WARN - now testing with needle
{ 'x-powered-by': 'Express',
'content-type': 'application/json; charset=utf-8',
'content-length': '4591',
date: 'Thu, 11 Dec 2014 14:32:52 GMT',
connection: 'close' }
Requestify
15:32:52 - WARN - now testing with requestify
{ 'x-powered-by': 'Express',
'content-type': 'application/json; charset=utf-8',
'content-length': '4591',
date: 'Thu, 11 Dec 2014 14:32:52 GMT',
connection: 'keep-alive' }
는 여기 wget을 가진 결과 헤더의
Connecting to localhost (localhost)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
X-Powered-By: Express
Accept-Ranges: bytes
Date: Thu, 11 Dec 2014 14:38:49 GMT
Cache-Control: public, max-age=0
Last-Modified: Thu, 11 Dec 2014 09:56:58 GMT
ETag: W/"7c2-2140188116"
Content-Type: text/html; charset=UTF-8
Content-Length: 1986
set-cookie: session=s%3AHI2alIkPOxVLXgJCymvAPbTZt1urIpEE.dBB7ZrpWjKAkwSALBVgbyJtRq9ZABMq9VJh%2F3XT6r8A; Path=/; Expires=Thu, 11 Dec 2014 15:08:49 GMT; HttpOnly
Connection: keep-alive
Length: 1986 (1.9K) [text/html]
이 도움이 될 수 있다면, 여기 내 헤더는 내 요청 출신
var commonHeaders = {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'fr',
'Cache-Control': 'no-cache',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'User-Agent': 'request'
};
firefox, chrome 및 wget이 전체 헤더를 가져올 수 있지만 노드 인증을 수행 할 수 없습니다. 노드에 문제가 있습니까? 파이썬에서 그렇게해야합니까?
는편집 : 노드를 통해 게시 된 데이터를 제거하는 것을 시도했다
, 나는 또한 wget을보다 동일한 응답을 가지고있다. 브라우저를 사용하고 로그인 작업을 수행하는 동안 json + set-cookie가 반환됩니다.
왜 노드에서 가능하지 않습니까?
두 개의 다른 URL/요청을 요청한 것 같습니다. wget은'text/html'과 다른 헤더를 보는 반면, 노드 요청은'application/json'과 더 적은 헤더를 보게됩니다. – mscdex
네, 맞습니다. 요청에 게시 된 데이터를 제거하면 노드에서 setCookie도 수신하게됩니다. 하지만 statusCode 401 및 user이거나 로그인으로 리디렉션됩니다. 것은 브라우저에서 로그인 액션을 사용하면 설정 쿠키를 반환해야합니다. – BigDong