/usr/share/doc/python3-pycurl/tests
NameSizeModeActions
certs/-0755rm
ext/-0755rm
fake-curl/-0755rm
fixtures/-0755rm
matrix/-0755rm
tmp/-0755rm
__pycache__/-0755rm
app.py40880644editdlrm
appmanager.py13800644editdlrm
cadata_test.py14520644editdlrm
certinfo_test.py34680644editdlrm
close_socket_cb_test.py21680644editdlrm
curl_object_test.py48830644editdlrm
debug_test.py22750644editdlrm
default_write_cb_test.py30390644editdlrm
error_constants_test.py6620644editdlrm
error_test.py29010644editdlrm
failonerror_test.py35090644editdlrm
ftp_test.py15370644editdlrm
global_init_test.py10630644editdlrm
header_cb_test.py15600644editdlrm
header_test.py18480644editdlrm
high_level_curl_test.py6320644editdlrm
info_constants_test.py3870644editdlrm
internals_test.py66740644editdlrm
matrix.py68160644editdlrm
multi_option_constants_test.py25030644editdlrm
multi_socket_test.py30490644editdlrm
multi_test.py123130644editdlrm
multi_timer_test.py26950644editdlrm
open_socket_cb_test.py47610644editdlrm
option_constants_test.py163710644editdlrm
perform_test.py21790644editdlrm
procmgr.py27310644editdlrm
protocol_constants_test.py16790644editdlrm
readdata_test.py96230644editdlrm
read_cb_test.py43400644editdlrm
relative_url_test.py5510644editdlrm
reload_test.py4300644editdlrm
reset_test.py26990644editdlrm
resolve_test.py7800644editdlrm
run-quickstart.sh7680755editdlrm
run.sh6900755editdlrm
runwsgi.py37330644editdlrm
seek_cb_constants_test.py8330644editdlrm
setopt_lifecycle_test.py17970644editdlrm
setopt_string_test.py8160644editdlrm
setopt_test.py37730644editdlrm
setopt_unicode_test.py10920644editdlrm
setup_test.py100350644editdlrm
share_test.py17260644editdlrm
sockopt_cb_test.py24530644editdlrm
unset_range_test.py14820644editdlrm
user_agent_string_test.py8200644editdlrm
util.py82910644editdlrm
version_comparison_test.py5140644editdlrm
version_constants_test.py20560644editdlrm
version_test.py3130644editdlrm
vsftpd.conf2940644editdlrm
weakref_test.py4430644editdlrm
write_abort_test.py11940644editdlrm
write_cb_bogus_test.py13810644editdlrm
write_test.py100480644editdlrm
write_to_stringio_test.py12280644editdlrm
xferinfo_cb_test.py21470644editdlrm
__init__.py5350644editdlrm
Edit: /usr/share/doc/python3-pycurl/tests/app.py (4088B)
# -*- coding: utf-8 -*- # vi:ts=4:et import time as _time, sys import bottle try: import json except ImportError: import simplejson as json py3 = sys.version_info[0] == 3 app = bottle.Bottle() app.debug = True @app.route('/success') def ok(): return 'success' @app.route('/short_wait') def short_wait(): _time.sleep(0.1) return 'success' @app.route('/status/403') def forbidden(): return bottle.HTTPResponse('forbidden', 403) @app.route('/status/404') def not_found(): return bottle.HTTPResponse('not found', 404) @app.route('/postfields', method='post') def postfields(): return json.dumps(dict(bottle.request.forms)) @app.route('/raw_utf8', method='post') def raw_utf8(): data = bottle.request.body.getvalue().decode('utf8') return json.dumps(data) # XXX file is not a bottle FileUpload instance, but FieldStorage? def xconvert_file(key, file): return { 'key': key, 'name': file.name, 'raw_filename': file.raw_filename, 'headers': file.headers, 'content_type': file.content_type, 'content_length': file.content_length, 'data': file.read(), } if hasattr(bottle, 'FileUpload'): # bottle 0.12 def convert_file(key, file): return { 'name': file.name, # file.filename lowercases the file name # https://github.com/defnull/bottle/issues/582 # raw_filenames is a string on python 3 'filename': file.raw_filename, 'data': file.file.read().decode(), } else: # bottle 0.11 def convert_file(key, file): return { 'name': file.name, 'filename': file.filename, 'data': file.file.read().decode(), } @app.route('/files', method='post') def files(): files = [convert_file(key, bottle.request.files[key]) for key in bottle.request.files] return json.dumps(files) @app.route('/header') def header(): return bottle.request.headers.get(bottle.request.query['h'], '') # This is a hacky endpoint to test non-ascii text being given to libcurl # via headers. # HTTP RFC requires headers to be latin1-encoded. # Any string can be decoded as latin1; here we encode the header value # back into latin1 to obtain original bytestring, then decode it in utf-8. # Thanks to bdarnell for the idea: https://github.com/pycurl/pycurl/issues/124 @app.route('/header_utf8') def header_utf8(): header_value = bottle.request.headers[bottle.request.query['h']] if py3: # header_value is a string, headers are decoded in latin1 header_value = header_value.encode('latin1').decode('utf8') else: # header_value is a binary string, decode in utf-8 directly header_value = header_value.decode('utf8') return header_value @app.route('/param_utf8_hack', method='post') def param_utf8_hack(): param = bottle.request.forms['p'] if py3: # python 3 decodes bytes as latin1 perhaps? # apply the latin1-utf8 hack param = param.encode('latin').decode('utf8') return param def pause_writer(interval): yield 'part1' _time.sleep(interval) yield 'part2' @app.route('/pause') def pause(): return pause_writer(0.5) @app.route('/long_pause') def long_pause(): return pause_writer(1) @app.route('/utf8_body') def utf8_body(): # bottle encodes the body return 'Дружба народов' @app.route('/invalid_utf8_body') def invalid_utf8_body(): # bottle encodes the body raise bottle.HTTPResponse(b'\xb3\xd2\xda\xcd\xd7', 200) @app.route('/set_cookie_invalid_utf8') def set_cookie_invalid_utf8(): bottle.response.set_header('Set-Cookie', '\xb3\xd2\xda\xcd\xd7=%96%A6g%9Ay%B0%A5g%A7tm%7C%95%9A') return 'cookie set' @app.route('/content_type_invalid_utf8') def content_type_invalid_utf8(): bottle.response.set_header('Content-Type', '\xb3\xd2\xda\xcd\xd7') return 'content type set' @app.route('/status_invalid_utf8') def status_invalid_utf8(): raise bottle.HTTPResponse('status set', '555 \xb3\xd2\xda\xcd\xd7')