Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Redirect request and response headers.

Post Reply
igor666
Posts: 64
Joined: Fri Feb 08, 2019 1:25 pm

Redirect request and response headers.

Post by igor666 »

Thanks for the answer in the previous post.
Now the problem is next - a request is made to the login.php page, which sets cookies upon successful authorization and redirects to the work_surfer.php page. In the Chrome browser, the developer’s tools show the response headers (login.php page):

Code: Select all

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 20
Content-Type: text/html; charset=utf-8
Date: Fri, 15 Mar 2019 11:11:42 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Location: /work_surfer.php
Pragma: no-cache
Set-Cookie: sess=0OqmaKkTuk0b; path=/; domain=ipgold.ru
Set-Cookie: login=igor666; expires=Mon, 14-Mar-2022 11:11:42 GMT; Max-Age=94608000; path=/; domain=ipgold.ru
Vary: Accept-Encoding
X-Powered-By: PHP/5.6.33
In oldcef4delphi in the deltools response heders looks like:

Code: Select all

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Encoding:gzip
Content-Length:20
Content-Type:text/html; charset=utf-8
Date:Fri, 15 Mar 2019 12:05:09 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Location:/work_surfer.php
Pragma:no-cache
Server:Apache/2.2.22 (Unix) PHP/5.6.33
Vary:Accept-Encoding
X-Powered-By:PHP/5.6.33
Why DevTools oldCEF4Delphi not see headers "Set-Cookie"? And how to access the response headers on the redirect page? Event OnResourceResponse not trigger on login.php page, it trigger only work_surfer.php page. I need to catch the creation of cookies and substitute a parameter in the request on page work_surfer.php
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Redirect request and response headers.

Post by salvadordf »

Sorry for the delayed answer.

I'm very busy and I haven't checked why is that happening.

OldCEF4Delphi is based in an old CEF3 version which includes an old Chromium version. It seems likely that the different behavior like missing events or different HTTP headers is caused by that.
igor666
Posts: 64
Joined: Fri Feb 08, 2019 1:25 pm

Re: Redirect request and response headers.

Post by igor666 »

Thanks for the answer, but the headers in the browser on the Windows XP operating system (Chrome 49) are similar to what I described above, that is, the matter is not in the old CEF3. Also, Chrome 49 sees the Cookie headers in the final request, and the devtools OLDCEF4Delphi does not see them.

Chrome 49 header after redirect from login.php to work_surf.php

Code: Select all

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Cookie:PHPSESSID=q9gbf9pkmiot94gk1lip37uuf6; sess=JmwkIeQFtEU1; login=mylogin
Host:www.somesite.ru
Referer:http://www.somesite.ru/work_surfer.php
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
oldcef4delphi headers

Code: Select all

Request Headers
Provisional headers are shown
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer:http://www.somesite.ru/work_surfer.php
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
I am confused by the inscription "Provisional headers are shown" in front of the headers ...
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Redirect request and response headers.

Post by salvadordf »

Try using other TChromium event with a ICefRequest parameter. Not all events show the same headers and perhaps some other event has the headers that you need.

As you can see in the source code, OldCEF4Delphi and CEF4Delphi only pass the ICefRequest parameter, except the TChromium.OnBeforeResourceLoad event where a header is added.

Chromium decides what information is available to CEF3 and CEF3 decides what information is available to CEF4Delphi / OldCEF4Delphi.
Image
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Redirect request and response headers.

Post by salvadordf »

I forgot that OldCEF4Delphi also has a GlobalCEFApp.OnBeforeNavigation event with a ICefRequest parameter that has more information. If I remember correctly, you could even access the POST data in that event.

However, that event is triggered in the render process and you would need to send that information to the browser process using a process message.
igor666
Posts: 64
Joined: Fri Feb 08, 2019 1:25 pm

Re: Redirect request and response headers.

Post by igor666 »

Unfortunately in the onbeforenavigate event, the headers don't seem to be at all.
request.getheadermap(h); h.size; - all the time returns 0.
Thank you for trying to help :). Most likely I will rebuild the logic without using cookies and headers.
Post Reply