SORU
14 NİSAN 2013, Pazar


komut satırı üzerinden çerez göndermek için nasıl?curl:

Send cookies with curl çalışır, ama benim için değil okudum

REST bir bitiş noktası var

class LoginResource(restful.Resource):
    def get(self):
        print(session)
        if 'USER_TOKEN' in session:
            return 'OK'
        return 'not authorized', 401

olarak erişmeye çalıştığımda

curl -v -b ~/Downloads/cookies.txt -c ~/Downloads/cookies.txt http://127.0.0.1:5000/
* About to connect() to 127.0.0.1 port 5000 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.27.0
> Host: 127.0.0.1:5000
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 401 UNAUTHORIZED
< Content-Type: application/json
< Content-Length: 16
< Server: Werkzeug/0.8.3 Python/2.7.2
< Date: Sun, 14 Apr 2013 04:45:45 GMT
<
* Closing connection #0
"not authorized"%

benim 9******

cat ~/Downloads/cookies.txt
USER_TOKEN=in

ve sunucu hiçbir şey alır

127.0.0.1 - - [13/Apr/2013 21:43:52] "GET / HTTP/1.1" 401 -
127.0.0.1 - - [13/Apr/2013 21:45:30] "GET / HTTP/1.1" 401 -
<SecureCookieSession {}>
<SecureCookieSession {}>
127.0.0.1 - - [13/Apr/2013 21:45:45] "GET / HTTP/1.1" 401 -

kaçırdığım nedir?

CEVAP
14 NİSAN 2013, Pazar


Bu benim için çalıştı

 curl -v --cookie "USER_TOKEN=Yes" http://127.0.0.1:5000/

Arka uç değeri kullanarak görebiliyordu

print request.cookies

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Just So

    Just So

    3 HAZİRAN 2007
  • Kim Barbin

    Kim Barbin

    3 Mayıs 2012
  • TheXiaxue

    TheXiaxue

    3 AĞUSTOS 2009