Httpie: Unterstützung für Cookies?

Erstellt am 6. März 2012  ·  6Kommentare  ·  Quelle: httpie/httpie

Gibt es Unterstützung für Cookies?

Die zugrunde liegende Anforderungsbibliothek scheint Cookies zu unterstützen ....

Prost,

Govinda

question

Hilfreichster Kommentar

Ja, Sie können Cookies wie alle anderen Header angeben:

$ http GET httpbin.org/cookies Cookie:hello=world
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 06 Mar 2012 13:19:45 GMT
Server: gunicorn/0.13.4
Content-Length: 43
Connection: keep-alive

{
    "cookies": {
        "hello": "world"
    }
}

(Siehe auch # 13.)

Meinst Du das?

Alle 6 Kommentare

Ja, Sie können Cookies wie alle anderen Header angeben:

$ http GET httpbin.org/cookies Cookie:hello=world
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 06 Mar 2012 13:19:45 GMT
Server: gunicorn/0.13.4
Content-Length: 43
Connection: keep-alive

{
    "cookies": {
        "hello": "world"
    }
}

(Siehe auch # 13.)

Meinst Du das?

@jakubroztocil Ich frage mich, ob vom Server gesetzte Cookies über Anrufe hinweg

@mcnemesis Ja, es gibt eine Sitzungsfunktion , mit der Cookies sowie benutzerdefinierte Header und Authentifizierungen zwischen Anforderungen beibehalten werden können.

Genial! Danke @jakubroztocil

@jakubroztocil Können wir json zum Setzen von Cookies verwenden?
Wie {'MOODLEID1_': '%250xxx5C2', 'MoodleSession': 'btsmxxxxxxxosn7'}

@NightMachinary können Sie eine Sitzungsdatei verwenden (https://httpie.org/docs#sessions):

Verwenden von cookies

$ cat  my-session.json
{
    "cookies": {
        "MOODLEID1_": {
            "value": "%250xxx5C2"
        },
        "MoodleSession": {
            "value": "btsmxxxxxxxosn7"
        }
    },
}
$ http --session ./my-session.json httpbin.org/headers
GET / HTTP/1.1
Cookie: MOODLEID1_=%250xxx5C2; MoodleSession=btsmxxxxxxxosn7

Verwenden von headers

$ cat  my-session.json
{
    "headers": {
        "Cookie": {
            "MOODLEID1_=%250xxx5C2; MoodleSession=btsmxxxxxxxosn7"
        }
    }
}
$ http --session ./my-session.json httpbin.org/headers
GET / HTTP/1.1
Cookie: MOODLEID1_=%250xxx5C2; MoodleSession=btsmxxxxxxxosn7
War diese Seite hilfreich?
0 / 5 - 0 Bewertungen