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

Set-Cookie 的问题. #35

Closed
yjdwbj opened this Issue Jan 6, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@yjdwbj

yjdwbj commented Jan 6, 2017

curl -v http://127.0.0.1:8888/iot/v1.0/app/auth/abc/123456/ -b "session=hW0X8q9k0PjoLe_bMVEyMA..|1483689794|jpsJApDD59qI9hcb6oM4vA..|EFDCyDPBZ1IrL7dSB6JctRWSawo.; Expires=Fri, 06 Jan 2017 08:03:14 GMT; Max-Age=3600; Path=/; SameSite=Lax; HttpOnly"
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
> GET /iot/v1.0/app/auth/abc/123456/ HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:8888
> Accept: */*
> Cookie: session=hW0X8q9k0PjoLe_bMVEyMA..|1483689794|jpsJApDD59qI9hcb6oM4vA..|EFDCyDPBZ1IrL7dSB6JctRWSawo.; Expires=Fri, 06 Jan 2017 08:03:14 GMT; Max-Age=3600; Path=/; SameSite=Lax; HttpOnly
> 
< HTTP/1.1 200 OK
* Server openresty/1.11.2.1 is not blacklisted
< Server: openresty/1.11.2.1
< Date: Fri, 06 Jan 2017 07:03:39 GMT
< Content-Type: text/plain; charset=utf8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: session=_DJqHt044CATcklg0wqc5Q..|1483689819|PIw1d7OsefTYWNO_0lKU5g..|9JYBHjc9pmF1v-CtVZxc0YbsNuI.; Expires=Fri, 06 Jan 2017 08:03:39 GMT; Max-Age=3600; Path=/; SameSite=Lax; HttpOnly
< X-Powered-By: Lor Framework
< 
 get data nil
debug  print table: 0x401ee088
 head is 
{"srvs":"127.0.0.10:1883","uuid":"f1852fcde4294f8c917522a12ec25fd1","time":"1483686219","sign":"D67CB6FE79412DC73B92E2EC5568C5C78B7FA76A","expire":600,"ok":true}
* Connection #0 to host 127.0.0.1 left intact

为什么,请求带了Cookie,服务器还是会返回Set-Cookie?有没有方法像Django一样,如果请求里没有Cookie,或者Cookie已经过期,就在返回里加上Set-Cookie.

下面是Django的实例

 curl -v http://127.0.0.1:8000/iot/v1.0/app/auth/abc/123456/ 
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> GET /iot/v1.0/app/auth/abc/123456/ HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:8000
> Accept: */*

* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Date: Fri, 06 Jan 2017 07:08:45 GMT
< Server: WSGIServer/0.1 Python/2.7.10
< Vary: Cookie
< X-Frame-Options: SAMEORIGIN
< Content-Type: application/json; charset=utf-8
< Set-Cookie:  sessionid=1tvksaww96ggfyrtn8ocrjxyv3q7lslz; expires=Fri, 06-Jan-2017 07:18:45 GMT; httponly; Max-Age=600; Path=/
< 
* Closing connection 0
{"ok": true, "uuid": "f1852fcde4294f8c917522a12ec25fd1", "sign": "1tvksaww96ggfyrtn8ocrjxyv3q7lslz", "srvs": "127.0.0.1:1883", "expire": 600, "time": "1483686525"}

yjdwbj@mint17:~$ curl -v http://127.0.0.1:8000/iot/v1.0/app/auth/abc/123456/ -b "sessionid=1tvksaww96ggfyrtn8ocrjxyv3q7lslz; expires=Fri, 06-Jan-2017 07:18:45 GMT; httponly; Max-Age=600; Path=/"
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> GET /iot/v1.0/app/auth/abc/123456/ HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:8000
> Accept: */*
> Cookie: sessionid=1tvksaww96ggfyrtn8ocrjxyv3q7lslz; expires=Fri, 06-Jan-2017 07:18:45 GMT; httponly; Max-Age=600; Path=/
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Date: Fri, 06 Jan 2017 07:09:11 GMT
< Server: WSGIServer/0.1 Python/2.7.10
< X-Frame-Options: SAMEORIGIN
< Content-Type: application/json; charset=utf-8
< 
* Closing connection 0
{"ok": true, "uuid": "f1852fcde4294f8c917522a12ec25fd1", "sign": "1tvksaww96ggfyrtn8ocrjxyv3q7lslz", "srvs": "127.0.0.1:1883", "expire": 600, "time": "1483686551"}
@sumory

This comment has been minimized.

Show comment
Hide comment
@sumory

sumory Jan 6, 2017

Owner

cookie的使用请参考lua-resty-cookie

Owner

sumory commented Jan 6, 2017

cookie的使用请参考lua-resty-cookie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment