Comments (7)
Can you provide some debug logs of what exactly is happening? Which callbacks
are being called and in which order? Please copy all callbacks from
LoadHandler/RequestHandler from the wxpython.py example and add them in the
wxpython-response.py example. This will provide detailed logs.
Original comment by [email protected]
on 16 Feb 2015 at 2:49
from cefpython.
There is a callback named OnResourceRedirect in RequestHandler. It would be a
good idea to check what is its relation to resource handler, if any.
Original comment by [email protected]
on 16 Feb 2015 at 2:51
from cefpython.
I attached the wxpython-response.py script with the changes you requested. This
is its log output:
{{{
[0216/135809:INFO:gpu_info_collector_x11.cc(80)] NVCtrl extension does not
exist.
wx.version=2.8.12.1 (gtk2-unicode)
[wxpython.py] RequestHandler::OnBeforeBrowse()
url = http://httpbin.org/redirect-to?url=/status/418
[wxpython.py] RequestHandler::OnBeforeResourceLoad()
url = http://httpbin.org/redirect-to?url=/status/418
GetResourceHandler(): url = http://httpbin.org/redirect-to?url=/status/418
[wxpython.py] RequestHandler::GetCookieManager(): created cookie manager
ProcessRequest()
OnRequestComplete()
status = Unknown
error code = 0
_OnResourceResponse()
data length = 135
GetResponseHeaders()
headers:
{'Content-Length': '135', 'x-more-info': 'http://tools.ietf.org/html/rfc2324',
'Server': 'nginx', 'Connection': 'keep-alive',
'Access-Control-Allow-Credentials': 'true', 'Date': 'Mon, 16 Feb 2015 15:58:10
GMT', 'Access-Control-Allow-Origin': '*'}
[wxpython.py] LoadHandler::OnLoadStart()
frame url = http://httpbin.org/redirect-to?url=/status/418
[wxpython.py] LoadHandler::OnLoadingStateChange()
isLoading = False, canGoBack = False, canGoForward = False
[wxpython.py] LoadHandler::OnLoadEnd()
frame url = http://httpbin.org/redirect-to?url=/status/418
http status code = 418
}}}
OnResourceRedirect doesn't seem to be getting called.
Original comment by [email protected]
on 16 Feb 2015 at 4:04
Attachments:
from cefpython.
This is what the wxpython.py example script outputs when I only change its
navigateUrl parameter. This is the desired behavior, so I'll try to see what
difference between the two script is causing the issue. I'm new to these
interfaces though so I appreciate any help from someone more experienced.
[wxpython.py] wx.version=2.8.12.1 (gtk2-unicode)
[CEF Python] Initialize() called
[CEF Python] CefExecuteProcess(): exitCode = -1
[CEF Python] CefInitialize()
[CEF Python] App_OnBeforeCommandLineProcessing_BrowserProcess()
[CEF Python] Command line string for the browser process:
--browser-subprocess-path=/usr/lib/pymodules/python2.7/cefpython3/subprocess
--lang=en-US --log-file=/tmp/debug.log --log-severity=info
--enable-release-dcheck
--resources-dir-path=/usr/lib/pymodules/python2.7/cefpython3
--locales-dir-path=/usr/lib/pymodules/python2.7/cefpython3/locales
--remote-debugging-port=52766 --no-sandbox
[CEF Python] BrowserProcessHandler_OnBeforeChildProcessLaunch()
[0216/140943:INFO:gpu_info_collector_x11.cc(80)] NVCtrl extension does not
exist.
[CEF Python] WindowUtils::IsWindowHandle() not implemented (always True)
[CEF Python] CreateBrowserSync() called
[CEF Python] navigateUrl: http://httpbin.org/redirect-to?url=/status/418
[CEF Python] CefBrowser::CreateBrowserSync()
[CEF Python] GetPyBrowser(): creating new PyBrowser, browserId=1
[wxpython.py] LifespanHandler::_OnAfterCreated()
browserId=1
[CEF Python] BrowserProcessHandler_OnBeforeChildProcessLaunch()
[CEF Python] CefBrowser::CreateBrowserSync() succeeded
[CEF Python] SendProcessMessage(): message=DoJavascriptBindings, arguments
size=1
[CEF Python] Command line string for the zygote process:
/usr/lib/pymodules/python2.7/cefpython3/subprocess --type=zygote --no-sandbox
--enable-release-dcheck --lang=en-US
--locales-dir-path=/usr/lib/pymodules/python2.7/cefpython3/locales
--log-file=/tmp/debug.log --log-severity=info
--resources-dir-path=/usr/lib/pymodules/python2.7/cefpython3
[CEF Python] Renderer: OnProcessMessageReceived(): DoJavascriptBindings
[wxpython.py] RequestHandler::OnBeforeBrowse()
url = http://httpbin.org/redirect-to?url=/status/418
[wxpython.py] RequestHandler::OnBeforeResourceLoad()
url = http://httpbin.org/redirect-to?url=/status/418
[wxpython.py] RequestHandler::GetCookieManager(): created cookie manager
[CEF Python] Renderer: OnContextCreated()
[CEF Python] Renderer: DoJavascriptBindingsForFrame(): bindings are set
[CEF Python] Browser: OnProcessMessageReceived(): OnContextCreated
[CEF Python] V8ContextHandler_OnContextCreated()
[CEF Python] Renderer: DoJavascriptBindingsForFrame(): bindings are set
[wxpython.py] RequestHandler::OnResourceRedirect()
old url = http://httpbin.org/redirect-to?url=/status/418
new url = http://httpbin.org/status/418
[wxpython.py] RequestHandler::OnBeforeBrowse()
url = http://httpbin.org/redirect-to?url=/status/418
[wxpython.py] RequestHandler::OnBeforeResourceLoad()
url = http://httpbin.org/status/418
[CEF Python] BrowserProcessHandler_OnBeforeChildProcessLaunch()
[wxpython.py] LoadHandler::OnLoadStart()
frame url = http://httpbin.org/status/418
[wxpython.py] DisplayHandler::OnAddressChange()
url = http://httpbin.org/status/418
[wxpython.py] LoadHandler::OnLoadingStateChange()
isLoading = False, canGoBack = False, canGoForward = False
[wxpython.py] DisplayHandler::OnTitleChange()
title = httpbin.org/status/418
[wxpython.py] LoadHandler::OnLoadEnd()
frame url = http://httpbin.org/status/418
http status code = 418
Original comment by [email protected]
on 16 Feb 2015 at 4:15
from cefpython.
So as I understand the redirect takes place and works fine. You are seeing the
same content in browser as in google chrome. The only problem is that the wrong
url being presented at the end of the request? Why is that a problem in your
case?
What are the values of webRequest.GetRequestStatus() and webRequest.GetUrl() in
OnRequestComplete?
Looks to me we need to set |redirectUrlOut| in GetResponseHeaders(). But I
don't see a way to do that when using CEFUrlRequest (named WebRequest in
cefpython).
Found this issue in CEF, which is to provide a way to detect redirects when
using CEFUrlRequest:
https://code.google.com/p/chromiumembedded/issues/detail?id=1329
(and a corresponding CEF topic:
http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11899)
It is not required to use WebRequest (CEFUrlRequest) to do a request. It is
just a helper API exposed by CEF. You could as well use Python's urllib.request
or similar to perform requests (but you might need to take care of user-agent
and other headears that simulate Google Chrome behavior). Just noting this in
case you don't want to wait for a fix in upstream CEF. In such case handle
redirects by setting redirectUrlOut in GetResponseHeaders.
Original comment by [email protected]
on 16 Feb 2015 at 5:07
from cefpython.
Yes, that's a problem for me because I'm doing web scraping and I need to know
the final url. Also I can't make another request using urllib because it's not
uncommon for websites to do redirects using javascript or meta tags.
Thanks for investigating the issue. Fortunately while going over the
differences between the two scripts I found that OnLoadEnd gives me the status
code without needing to go through the whole ResouceHandler/WebRequest flow,
which is much simpler and doesn't break the final location in the browser.
Original comment by [email protected]
on 16 Feb 2015 at 6:21
from cefpython.
Original comment by [email protected]
on 16 Feb 2015 at 6:30
- Changed title: wxpython-response.py example: final url is wrong when doing redirects
- Changed state: Accepted
from cefpython.
Related Issues (20)
- The default en-US locale pak file fails to load on Mac HOT 3
- Examples crash on Mac when app doesn't have permission to write to the debug.log file
- Issues with size_t => int conversions when using cef_values.h API on Win x64 platform HOT 2
- Python Wheels - DESCRIPTION.rst UNKNOWN
- Embed __version__ also in the cython generated module (cefpython_py27.pyd) HOT 1
- Create unified key mappings for all platforms HOT 8
- Add Browser.IsDevTools() HOT 1
- Expose CreateBrowser() with a callback argument that will be executed after browser was created
- The popup window and parent window can't script each other in the wxpython.py example HOT 3
- Create "chrome31" branch before updating to a newer CEF branch HOT 1
- Close the browser BEFORE the page is full loaded CEF Crashe HOT 1
- Warnings on OS X: Internals of CFAllocator not known HOT 1
- [meta] Migrate the repository somewhere HOT 2
- Gtk: gtk_disable_setlocale() must be called before gtk_init() HOT 2
- Restructure directories (binaries, installer, libraries) to allow for git branching HOT 1
- Automating navigation HOT 1
- Google Code is dying
- Update to CEF branch 2171 (Chrome 39) HOT 1
- Ability to pass modifiers to SendMouseMoveEvent and similar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cefpython.