Data in the response_body using the GIR bindings from Python



Dear List,

I started using libsoup in a Python2 project with Gtk3, using the GIR
bindings. Unfortunately, I'm not exactly sure I'm doing it right as
some things do not seem to work as described in the documentation (but
I found workarounds for that) and for some code, Python crashes with a
segmentation fault.
About the difference to the documentation: I was under the impression
that after a successful request, the full message body is contained in
message.request_body.data. However, this is not the case, even after
calling .flatten() on the request_body, the data field only contains
something like the first chunk of the response. My workaround right
now is to use the buffer returned by the flatten function, this does
indeed contain the whole data.
Unfortunately, this buffer object seems to be a bit "fragile" -- doing
some pythonic stuff  (like asking for its length with len(...) or
checking it for being not empty with "if buffer:...") leads to
segmentation faults. I also encountered another one which seemed to
have to do with it getting freed by the garbage collector, but this is
a bit harder to reproduce.
I uploaded a simple python script exhibiting those issues to
http://paste.ubuntu.com/876804/

Any helpful suggestions or comments? Should I open a bug report for it
or am I doing something wrong?

Thanks a lot,
 Marcel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]