A
A
aibb2021-04-13 23:44:39
Java
aibb, 2021-04-13 23:44:39

How to get all Cookies after a GET request?

I open the site page in chrome, I immediately look at the cookies in the developer tools (Network -> Cookies):

6075fe182d0d5252917580.png
Of those on the screen, I can only get JSESSIONID.

Further on Network -> Headers for the same request:
6076002ed375b487292984.png
1) What put down all these headings? After all, as I understand it, they were put BEFORE the request, and not after, if not, then why are they in Request Headers ?

Accordingly, I get only Response Headers in the script, which is logical in principle, but then it's not clear where the rest of the cookies are?
607601d8c0327322271696.png

Cookies to output stream:

class Main {
    static void main(String[] args) {
        URL myUrl = new URL("https://example.ru/index.html")
        URLConnection urlConn = myUrl.openConnection()
        urlConn.connect()

        def temp = null

        for (int i = 1; urlConn.getHeaderFieldKey(i) != null; i++) {
            println("${urlConn.getHeaderFieldKey(i)} : ${urlConn.getHeaderField(i)}")
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question