How to obtain the request headers that was sent after I get or post a request to the endpointHow to get the current time in PythonHow do I sort a dictionary by value?How do I set/unset a cookie with jQuery?How do I get the number of elements in a list?Why is jquery's .ajax() method not sending my session cookie?Generate random integers between 0 and 9Do sessions really violate RESTfulness?How to fix “Headers already sent” error in PHPGet list from pandas DataFrame column headersWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?
Other Space Shuttle O-ring failures
Passwordless authentication - how and when to invalidate a login code
Tesco's Burger Relish Best Before End date number
3-way switches no longer serving their purpose
Interpretation of non-significant results as "trends"
How to slice a string input at a certain unknown index
When do flights get cancelled due to fog?
QR codes, do people use them?
What exactly is a "murder hobo"?
How many Jimmys can fit?
Moving millions of files to a different directory with specfic name patterns
Why did Robert F. Kennedy loathe Lyndon B. Johnson?
Confusion in M2 Professional certification question - 1
Why "Supports 5V VCC operation" appeared in LVC family datasheets?
Is there a formal/better word than "skyrocket" for the given context?
I'm feeling like my character doesn't fit the campaign
The Apéry's constant and the Airy function
Does anyone have a method of differentiating informative comments from commented out code?
Pages: Fit two A5 page on on a single A4 page in landscape mode
This LM317 diagram doesn't make any sense to me
Is this really the Saturn V computer only, or are there other systems here as well?
How do ballistic trajectories work in a ring world?
How to use Adostop Eco stop bath?
How to obtain the request headers that was sent after I get or post a request to the endpoint
How to get the current time in PythonHow do I sort a dictionary by value?How do I set/unset a cookie with jQuery?How do I get the number of elements in a list?Why is jquery's .ajax() method not sending my session cookie?Generate random integers between 0 and 9Do sessions really violate RESTfulness?How to fix “Headers already sent” error in PHPGet list from pandas DataFrame column headersWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How do I retrieve one of the parameters that's generated in the requests header? I need it in order to maintain the session.

For example I need the cookie parameter that's generated in the requests header.
python cookies header python-requests
|
show 2 more comments
How do I retrieve one of the parameters that's generated in the requests header? I need it in order to maintain the session.

For example I need the cookie parameter that's generated in the requests header.
python cookies header python-requests
r.request.headerswhereris the response object.
– t.m.adam
Mar 25 at 22:20
right, that gives me the response headers, but I want the request headers
– stanley4430
Mar 25 at 22:22
r.request.headerscontains the request headers,r.headerscontains the response headers.
– t.m.adam
Mar 25 at 22:24
I see. Thanks for the clarification. But for some reason it doesn't give me all the request headers and it skips over the part that I actually need. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'
– stanley4430
Mar 25 at 22:31
Those are the request headers, assuming you changed the default User-Agent. If you just want the cookies you can user.cookies(it's a CookieJar object but you can get a gictionary withr.cookies.get_dict()). If you wantrequeststo store and use cookies you can use aSession()object.
– t.m.adam
Mar 25 at 22:35
|
show 2 more comments
How do I retrieve one of the parameters that's generated in the requests header? I need it in order to maintain the session.

For example I need the cookie parameter that's generated in the requests header.
python cookies header python-requests
How do I retrieve one of the parameters that's generated in the requests header? I need it in order to maintain the session.

For example I need the cookie parameter that's generated in the requests header.
python cookies header python-requests
python cookies header python-requests
edited Mar 25 at 22:26
t.m.adam
11.7k3 gold badges16 silver badges37 bronze badges
11.7k3 gold badges16 silver badges37 bronze badges
asked Mar 25 at 22:16
stanley4430stanley4430
1
1
r.request.headerswhereris the response object.
– t.m.adam
Mar 25 at 22:20
right, that gives me the response headers, but I want the request headers
– stanley4430
Mar 25 at 22:22
r.request.headerscontains the request headers,r.headerscontains the response headers.
– t.m.adam
Mar 25 at 22:24
I see. Thanks for the clarification. But for some reason it doesn't give me all the request headers and it skips over the part that I actually need. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'
– stanley4430
Mar 25 at 22:31
Those are the request headers, assuming you changed the default User-Agent. If you just want the cookies you can user.cookies(it's a CookieJar object but you can get a gictionary withr.cookies.get_dict()). If you wantrequeststo store and use cookies you can use aSession()object.
– t.m.adam
Mar 25 at 22:35
|
show 2 more comments
r.request.headerswhereris the response object.
– t.m.adam
Mar 25 at 22:20
right, that gives me the response headers, but I want the request headers
– stanley4430
Mar 25 at 22:22
r.request.headerscontains the request headers,r.headerscontains the response headers.
– t.m.adam
Mar 25 at 22:24
I see. Thanks for the clarification. But for some reason it doesn't give me all the request headers and it skips over the part that I actually need. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'
– stanley4430
Mar 25 at 22:31
Those are the request headers, assuming you changed the default User-Agent. If you just want the cookies you can user.cookies(it's a CookieJar object but you can get a gictionary withr.cookies.get_dict()). If you wantrequeststo store and use cookies you can use aSession()object.
– t.m.adam
Mar 25 at 22:35
r.request.headers where r is the response object.– t.m.adam
Mar 25 at 22:20
r.request.headers where r is the response object.– t.m.adam
Mar 25 at 22:20
right, that gives me the response headers, but I want the request headers
– stanley4430
Mar 25 at 22:22
right, that gives me the response headers, but I want the request headers
– stanley4430
Mar 25 at 22:22
r.request.headers contains the request headers, r.headers contains the response headers.– t.m.adam
Mar 25 at 22:24
r.request.headers contains the request headers, r.headers contains the response headers.– t.m.adam
Mar 25 at 22:24
I see. Thanks for the clarification. But for some reason it doesn't give me all the request headers and it skips over the part that I actually need. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'
– stanley4430
Mar 25 at 22:31
I see. Thanks for the clarification. But for some reason it doesn't give me all the request headers and it skips over the part that I actually need. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'
– stanley4430
Mar 25 at 22:31
Those are the request headers, assuming you changed the default User-Agent. If you just want the cookies you can use
r.cookies (it's a CookieJar object but you can get a gictionary with r.cookies.get_dict()). If you want requests to store and use cookies you can use a Session() object.– t.m.adam
Mar 25 at 22:35
Those are the request headers, assuming you changed the default User-Agent. If you just want the cookies you can use
r.cookies (it's a CookieJar object but you can get a gictionary with r.cookies.get_dict()). If you want requests to store and use cookies you can use a Session() object.– t.m.adam
Mar 25 at 22:35
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347203%2fhow-to-obtain-the-request-headers-that-was-sent-after-i-get-or-post-a-request-to%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347203%2fhow-to-obtain-the-request-headers-that-was-sent-after-i-get-or-post-a-request-to%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
r.request.headerswhereris the response object.– t.m.adam
Mar 25 at 22:20
right, that gives me the response headers, but I want the request headers
– stanley4430
Mar 25 at 22:22
r.request.headerscontains the request headers,r.headerscontains the response headers.– t.m.adam
Mar 25 at 22:24
I see. Thanks for the clarification. But for some reason it doesn't give me all the request headers and it skips over the part that I actually need. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'
– stanley4430
Mar 25 at 22:31
Those are the request headers, assuming you changed the default User-Agent. If you just want the cookies you can use
r.cookies(it's a CookieJar object but you can get a gictionary withr.cookies.get_dict()). If you wantrequeststo store and use cookies you can use aSession()object.– t.m.adam
Mar 25 at 22:35