post request doesn't work

121 views
Skip to first unread message

x3735...@gmail.com

unread,
Aug 12, 2018, 7:24:31 PM8/12/18
to CEF Python
Hi,
I wanted to make post request codes. And thus, I coded:
----------------------------------------------
req = cef.Request.CreateRequest()
req.SetUrl('https://httpbin.org/post')
req.SetMethod('POST')
req.SetPostData({'param2' : 'test'})
reqclient = WebRequestClient()
req2 = cef.WebRequest.Create(req, reqclient)
----------------------------------------------


However, it throws exception when I run codes via Python 3.6
----------------------------------------------------------------------------------
req.SetPostData({'param2' : 'test'})
File "request.pyx", line 117, in cefpython_py36.PyRequest.SetPostData (cefpython_py36.cpp:48900)
File "request.pyx", line 140, in cefpython_py36.PyRequest.SetPostData (cefpython_py36.cpp:48733)
AttributeError: module 'urllib' has no attribute 'urlencode'
----------------------------------------------------------------------------------


Whereas, it doesn't throw any exception via Python 2.7
And the post request works fine, too.
But the post data ({param2 : test} in this case) are not passed to request url.

I'm using latest stable release cefpython3 57.0
And OS is centos-release-7-5.1804.1.el7.centos.x86_64

Anyone please help me?
Thank you in advance.

Czarek Tomczak

unread,
Aug 13, 2018, 5:30:48 AM8/13/18
to CEF Python
I've just pushed a commit and this is now fixed for Python 3 in v66 release. You can build v66 using master branch and prebuilt binaries from GitHub Releases tagged v66-upstream. All dict strings passed to SetPostData are expected to be byte strings.

Czarek Tomczak

unread,
Aug 13, 2018, 5:32:48 AM8/13/18
to CEF Python
This is also fixed in Python 2.7 in v66. Post data is now passed correctly.

x3735...@gmail.com

unread,
Aug 13, 2018, 7:23:21 PM8/13/18
to CEF Python
It works now.
Thank you very much.

ps. btw I want to know if there is an any proper way to disable two newly appeared messages (from cef v66, I guess):
[0814/081449.254868:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
DevTools listening on ws://127.0.0.1:51980/devtools/browser/105617e2-4f22-4e39-92b3-60a267dfc06c

Czarek Tomczak

unread,
Aug 14, 2018, 3:22:17 AM8/14/18
to CEF Python
The "Lost UI shared context" I only saw appearing on Mac, it's a harmless error message.

Set ApplicationSettings.remote_debugging_port to -1 to disable DevTools and the message should disappear.

Both messages are hardcoded in Chromium, so you would need to build CEF from sources and patch Chromium to remove these:

1. https://cs.chromium.org/chromium/src/content/browser/compositor/gpu_process_transport_factory.cc?type=cs&q=%22Lost+UI+shared+context%22&sq=package:chromium&g=0&l=984

2. https://cs.chromium.org/chromium/src/content/browser/devtools/devtools_http_handler.cc?type=cs&q=%22devtools+listening+on%22&sq=package:chromium&g=0&l=274

Czarek Tomczak

unread,
Aug 14, 2018, 3:25:49 AM8/14/18
to CEF Python
Alternatively you can disable all logs completely by setting ApplicationSettings.log_severity to LOGSEVERITY_DISABLE and that will get rid of the error message.

x3735...@gmail.com

unread,
Aug 14, 2018, 4:37:36 AM8/14/18
to CEF Python
You saved me! Thank you!
Reply all
Reply to author
Forward
0 new messages