/usr/share/doc/python-werkzeug-doc/html/wrappers.html is in python-werkzeug-doc 0.10.4+dfsg1-1ubuntu1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Request / Response Objects — Werkzeug 0.10.4 documentation</title>
<link rel="stylesheet" href="_static/werkzeug.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.10.4',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Werkzeug 0.10.4 documentation" href="index.html" />
<link rel="next" title="URL Routing" href="routing.html" />
<link rel="prev" title="Debugging Applications" href="debug.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="routing.html" title="URL Routing"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="debug.html" title="Debugging Applications"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Werkzeug 0.10.4 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-werkzeug.wrappers">
<span id="request-response-objects"></span><span id="wrappers"></span><h1>Request / Response Objects<a class="headerlink" href="#module-werkzeug.wrappers" title="Permalink to this headline">¶</a></h1>
<p>The request and response objects wrap the WSGI environment or the return
value from a WSGI application so that it is another WSGI application
(wraps a whole application).</p>
<div class="section" id="how-they-work">
<h2>How they Work<a class="headerlink" href="#how-they-work" title="Permalink to this headline">¶</a></h2>
<p>Your WSGI application is always passed two arguments. The WSGI “environment”
and the WSGI <cite>start_response</cite> function that is used to start the response
phase. The <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal"><span class="pre">Request</span></code></a> class wraps the <cite>environ</cite> for easier access to
request variables (form data, request headers etc.).</p>
<p>The <a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal"><span class="pre">Response</span></code></a> on the other hand is a standard WSGI application that
you can create. The simple hello world in Werkzeug looks like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">Response</span>
<span class="n">application</span> <span class="o">=</span> <span class="n">Response</span><span class="p">(</span><span class="s1">'Hello World!'</span><span class="p">)</span>
</pre></div>
</div>
<p>To make it more useful you can replace it with a function and do some
processing:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">Request</span><span class="p">,</span> <span class="n">Response</span>
<span class="k">def</span> <span class="nf">application</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">):</span>
<span class="n">request</span> <span class="o">=</span> <span class="n">Request</span><span class="p">(</span><span class="n">environ</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">Response</span><span class="p">(</span><span class="s2">"Hello </span><span class="si">%s</span><span class="s2">!"</span> <span class="o">%</span> <span class="n">request</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'name'</span><span class="p">,</span> <span class="s1">'World!'</span><span class="p">))</span>
<span class="k">return</span> <span class="n">response</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">)</span>
</pre></div>
</div>
<p>Because this is a very common task the <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal"><span class="pre">Request</span></code></a> object provides
a helper for that. The above code can be rewritten like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">Request</span><span class="p">,</span> <span class="n">Response</span>
<span class="nd">@Request.application</span>
<span class="k">def</span> <span class="nf">application</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s2">"Hello </span><span class="si">%s</span><span class="s2">!"</span> <span class="o">%</span> <span class="n">request</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'name'</span><span class="p">,</span> <span class="s1">'World!'</span><span class="p">))</span>
</pre></div>
</div>
<p>The <cite>application</cite> is still a valid WSGI application that accepts the
environment and <cite>start_response</cite> callable.</p>
</div>
<div class="section" id="mutability-and-reusability-of-wrappers">
<h2>Mutability and Reusability of Wrappers<a class="headerlink" href="#mutability-and-reusability-of-wrappers" title="Permalink to this headline">¶</a></h2>
<p>The implementation of the Werkzeug request and response objects are trying
to guard you from common pitfalls by disallowing certain things as much as
possible. This serves two purposes: high performance and avoiding of
pitfalls.</p>
<p>For the request object the following rules apply:</p>
<ol class="arabic simple">
<li>The request object is immutable. Modifications are not supported by
default, you may however replace the immutable attributes with mutable
attributes if you need to modify it.</li>
<li>The request object may be shared in the same thread, but is not thread
safe itself. If you need to access it from multiple threads, use
locks around calls.</li>
<li>It’s not possible to pickle the request object.</li>
</ol>
<p>For the response object the following rules apply:</p>
<ol class="arabic simple">
<li>The response object is mutable</li>
<li>The response object can be pickled or copied after <cite>freeze()</cite> was
called.</li>
<li>Since Werkzeug 0.6 it’s safe to use the same response object for
multiple WSGI responses.</li>
<li>It’s possible to create copies using <cite>copy.deepcopy</cite>.</li>
</ol>
</div>
<div class="section" id="base-wrappers">
<h2>Base Wrappers<a class="headerlink" href="#base-wrappers" title="Permalink to this headline">¶</a></h2>
<p>These objects implement a common set of operations. They are missing fancy
addon functionality like user agent parsing or etag handling. These features
are available by mixing in various mixin classes or using <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal"><span class="pre">Request</span></code></a> and
<a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal"><span class="pre">Response</span></code></a>.</p>
<dl class="class">
<dt id="werkzeug.wrappers.BaseRequest">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">BaseRequest</code><span class="sig-paren">(</span><em>environ</em>, <em>populate_request=True</em>, <em>shallow=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest" title="Permalink to this definition">¶</a></dt>
<dd><p>Very basic request object. This does not implement advanced stuff like
entity tag parsing or cache controls. The request object is created with
the WSGI environment as first argument and will add itself to the WSGI
environment as <code class="docutils literal"><span class="pre">'werkzeug.request'</span></code> unless it’s created with
<cite>populate_request</cite> set to False.</p>
<p>There are a couple of mixins available that add additional functionality
to the request object, there is also a class called <cite>Request</cite> which
subclasses <cite>BaseRequest</cite> and all the important mixins.</p>
<p>It’s a good idea to create a custom subclass of the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></a>
and add missing functionality either via mixins or direct implementation.
Here an example for such subclasses:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">BaseRequest</span><span class="p">,</span> <span class="n">ETagRequestMixin</span>
<span class="k">class</span> <span class="nc">Request</span><span class="p">(</span><span class="n">BaseRequest</span><span class="p">,</span> <span class="n">ETagRequestMixin</span><span class="p">):</span>
<span class="k">pass</span>
</pre></div>
</div>
<p>Request objects are <strong>read only</strong>. As of 0.5 modifications are not
allowed in any place. Unlike the lower level parsing functions the
request object will use immutable objects everywhere possible.</p>
<p>Per default the request object will assume all the text data is <cite>utf-8</cite>
encoded. Please refer to <a class="reference external" href="unicode.txt">the unicode chapter</a> for more
details about customizing the behavior.</p>
<p>Per default the request object will be added to the WSGI
environment as <cite>werkzeug.request</cite> to support the debugging system.
If you don’t want that, set <cite>populate_request</cite> to <cite>False</cite>.</p>
<p>If <cite>shallow</cite> is <cite>True</cite> the environment is initialized as shallow
object around the environ. Every operation that would modify the
environ in any way (such as consuming form data) raises an exception
unless the <cite>shallow</cite> attribute is explicitly set to <cite>False</cite>. This
is useful for middlewares where you don’t want to consume the form
data by accident. A shallow request is not populated to the WSGI
environment.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>read-only mode was enforced by using immutables classes for all
data.</p>
</div>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.environ">
<code class="descname">environ</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.environ" title="Permalink to this definition">¶</a></dt>
<dd><p>The WSGI environment that the request object uses for data retrival.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.shallow">
<code class="descname">shallow</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.shallow" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>True</cite> if this request object is shallow (does not modify <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.environ" title="werkzeug.wrappers.BaseRequest.environ"><code class="xref py py-attr docutils literal"><span class="pre">environ</span></code></a>),
<cite>False</cite> otherwise.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest._get_file_stream">
<code class="descname">_get_file_stream</code><span class="sig-paren">(</span><em>total_content_length</em>, <em>content_type</em>, <em>filename=None</em>, <em>content_length=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest._get_file_stream" title="Permalink to this definition">¶</a></dt>
<dd><p>Called to get a stream for the file upload.</p>
<p>This must provide a file-like class with <cite>read()</cite>, <cite>readline()</cite>
and <cite>seek()</cite> methods that is both writeable and readable.</p>
<p>The default implementation returns a temporary file if the total
content length is higher than 500KB. Because many browsers do not
provide a content length for the files only the total content
length matters.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>total_content_length</strong> – the total content length of all the
data in the request combined. This value
is guaranteed to be there.</li>
<li><strong>content_type</strong> – the mimetype of the uploaded file.</li>
<li><strong>filename</strong> – the filename of the uploaded file. May be <cite>None</cite>.</li>
<li><strong>content_length</strong> – the length of this file. This value is usually
not provided because webbrowsers do not provide
this value.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.access_route">
<code class="descname">access_route</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.access_route" title="Permalink to this definition">¶</a></dt>
<dd><p>If a forwarded header exists this is a list of all ip addresses
from the client ip to the last proxy server.</p>
</dd></dl>
<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseRequest.application">
<em class="property">classmethod </em><code class="descname">application</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.application" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorate a function as responder that accepts the request as first
argument. This works like the <code class="xref py py-func docutils literal"><span class="pre">responder()</span></code> decorator but the
function is passed the request object as first argument and the
request object will be closed automatically:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="nd">@Request.application</span>
<span class="k">def</span> <span class="nf">my_wsgi_app</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s1">'Hello World!'</span><span class="p">)</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>f</strong> – the WSGI callable to decorate</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a new WSGI callable</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.args">
<code class="descname">args</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.args" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed URL parameters. By default an
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal"><span class="pre">ImmutableMultiDict</span></code></a>
is returned from this function. This can be changed by setting
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.parameter_storage_class" title="werkzeug.wrappers.BaseRequest.parameter_storage_class"><code class="xref py py-attr docutils literal"><span class="pre">parameter_storage_class</span></code></a> to a different type. This might
be necessary if the order of the form data is important.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.base_url">
<code class="descname">base_url</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.base_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.url" title="werkzeug.wrappers.BaseRequest.url"><code class="xref py py-attr docutils literal"><span class="pre">url</span></code></a> but without the querystring
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.charset">
<code class="descname">charset</code><em class="property"> = 'utf-8'</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>the charset for the request, defaults to utf-8</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes associated resources of this request object. This
closes all file handles explicitly. You can also use the request
object in a with statement with will automatically close it.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.cookies">
<code class="descname">cookies</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.cookies" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only access to the retrieved cookie values as dictionary.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.dict_storage_class">
<code class="descname">dict_storage_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.dict_storage_class" title="Permalink to this definition">¶</a></dt>
<dd><p>the type to be used for dict values from the incoming WSGI environment.
By default an
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableTypeConversionDict" title="werkzeug.datastructures.ImmutableTypeConversionDict"><code class="xref py py-class docutils literal"><span class="pre">ImmutableTypeConversionDict</span></code></a> is used
(for example for <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.cookies" title="werkzeug.wrappers.BaseRequest.cookies"><code class="xref py py-attr docutils literal"><span class="pre">cookies</span></code></a>).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<p>alias of <code class="xref py py-class docutils literal"><span class="pre">ImmutableTypeConversionDict</span></code></p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.disable_data_descriptor">
<code class="descname">disable_data_descriptor</code><em class="property"> = False</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.disable_data_descriptor" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates whether the data descriptor should be allowed to read and
buffer up the input stream. By default it’s enabled.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.encoding_errors">
<code class="descname">encoding_errors</code><em class="property"> = 'replace'</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.encoding_errors" title="Permalink to this definition">¶</a></dt>
<dd><p>the error handling procedure for errors, defaults to ‘replace’</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.files">
<code class="descname">files</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.files" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="datastructures.html#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal"><span class="pre">MultiDict</span></code></a> object containing
all uploaded files. Each key in <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal"><span class="pre">files</span></code></a> is the name from the
<code class="docutils literal"><span class="pre"><input</span> <span class="pre">type="file"</span> <span class="pre">name=""></span></code>. Each value in <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal"><span class="pre">files</span></code></a> is a
Werkzeug <a class="reference internal" href="datastructures.html#werkzeug.datastructures.FileStorage" title="werkzeug.datastructures.FileStorage"><code class="xref py py-class docutils literal"><span class="pre">FileStorage</span></code></a> object.</p>
<p>Note that <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal"><span class="pre">files</span></code></a> will only contain data if the request method was
POST, PUT or PATCH and the <code class="docutils literal"><span class="pre"><form></span></code> that posted to the request had
<code class="docutils literal"><span class="pre">enctype="multipart/form-data"</span></code>. It will be empty otherwise.</p>
<p>See the <a class="reference internal" href="datastructures.html#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal"><span class="pre">MultiDict</span></code></a> /
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.FileStorage" title="werkzeug.datastructures.FileStorage"><code class="xref py py-class docutils literal"><span class="pre">FileStorage</span></code></a> documentation for
more details about the used data structure.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.form">
<code class="descname">form</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.form" title="Permalink to this definition">¶</a></dt>
<dd><p>The form parameters. By default an
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal"><span class="pre">ImmutableMultiDict</span></code></a>
is returned from this function. This can be changed by setting
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.parameter_storage_class" title="werkzeug.wrappers.BaseRequest.parameter_storage_class"><code class="xref py py-attr docutils literal"><span class="pre">parameter_storage_class</span></code></a> to a different type. This might
be necessary if the order of the form data is important.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.form_data_parser_class">
<code class="descname">form_data_parser_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.form_data_parser_class" title="Permalink to this definition">¶</a></dt>
<dd><p>The form data parser that shoud be used. Can be replaced to customize
the form date parsing.</p>
<p>alias of <code class="xref py py-class docutils literal"><span class="pre">FormDataParser</span></code></p>
</dd></dl>
<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseRequest.from_values">
<em class="property">classmethod </em><code class="descname">from_values</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.from_values" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new request object based on the values provided. If
environ is given missing values are filled from there. This method is
useful for small scripts when you need to simulate a request from an URL.
Do not use this method for unittesting, there is a full featured client
object (<code class="xref py py-class docutils literal"><span class="pre">Client</span></code>) that allows to create multipart requests,
support for cookies etc.</p>
<p>This accepts the same options as the
<a class="reference internal" href="test.html#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a>.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>This method now accepts the same arguments as
<a class="reference internal" href="test.html#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal"><span class="pre">EnvironBuilder</span></code></a>. Because of this the
<cite>environ</cite> parameter is now called <cite>environ_overrides</cite>.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">request object</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.full_path">
<code class="descname">full_path</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.full_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Requested path as unicode, including the query string.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest.get_data">
<code class="descname">get_data</code><span class="sig-paren">(</span><em>cache=True</em>, <em>as_text=False</em>, <em>parse_form_data=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>This reads the buffered incoming data from the client into one
bytestring. By default this is cached but that behavior can be
changed by setting <cite>cache</cite> to <cite>False</cite>.</p>
<p>Usually it’s a bad idea to call this method without checking the
content length first as a client could send dozens of megabytes or more
to cause memory problems on the server.</p>
<p>Note that if the form data was already parsed this method will not
return anything as form data parsing does not cache the data like
this method does. To implicitly invoke form data parsing function
set <cite>parse_form_data</cite> to <cite>True</cite>. When this is done the return value
of this method will be an empty string if the form parser handles
the data. This generally is not necessary as if the whole data is
cached (which is the default) the form parser will used the cached
data to parse the form data. Please be generally aware of checking
the content length first in any case before calling this method
to avoid exhausting server memory.</p>
<p>If <cite>as_text</cite> is set to <cite>True</cite> the return value will be a decoded
unicode string.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>The headers from the WSGI environ as immutable
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.EnvironHeaders" title="werkzeug.datastructures.EnvironHeaders"><code class="xref py py-class docutils literal"><span class="pre">EnvironHeaders</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.host">
<code class="descname">host</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.host" title="Permalink to this definition">¶</a></dt>
<dd><p>Just the host including the port if available.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.host_url">
<code class="descname">host_url</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.host_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Just the host with scheme as IRI.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_multiprocess">
<code class="descname">is_multiprocess</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_multiprocess" title="Permalink to this definition">¶</a></dt>
<dd><p>boolean that is <cite>True</cite> if the application is served by
a WSGI server that spawns multiple processes.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_multithread">
<code class="descname">is_multithread</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_multithread" title="Permalink to this definition">¶</a></dt>
<dd><p>boolean that is <cite>True</cite> if the application is served by
a multithreaded WSGI server.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_run_once">
<code class="descname">is_run_once</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_run_once" title="Permalink to this definition">¶</a></dt>
<dd><p>boolean that is <cite>True</cite> if the application will be executed only
once in a process lifetime. This is the case for CGI for example,
but it’s not guaranteed that the exeuction only happens one time.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_secure">
<code class="descname">is_secure</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_secure" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>True</cite> if the request is secure.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_xhr">
<code class="descname">is_xhr</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_xhr" title="Permalink to this definition">¶</a></dt>
<dd><p>True if the request was triggered via a JavaScript XMLHttpRequest.
This only works with libraries that support the <cite>X-Requested-With</cite>
header and set it to “XMLHttpRequest”. Libraries that do that are
prototype, jQuery and Mochikit and probably some more.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.list_storage_class">
<code class="descname">list_storage_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.list_storage_class" title="Permalink to this definition">¶</a></dt>
<dd><p>the type to be used for list values from the incoming WSGI environment.
By default an <a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableList" title="werkzeug.datastructures.ImmutableList"><code class="xref py py-class docutils literal"><span class="pre">ImmutableList</span></code></a> is used
(for example for <code class="xref py py-attr docutils literal"><span class="pre">access_list</span></code>).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<p>alias of <code class="xref py py-class docutils literal"><span class="pre">ImmutableList</span></code></p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest.make_form_data_parser">
<code class="descname">make_form_data_parser</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.make_form_data_parser" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates the form data parser. Instanciates the
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form_data_parser_class" title="werkzeug.wrappers.BaseRequest.form_data_parser_class"><code class="xref py py-attr docutils literal"><span class="pre">form_data_parser_class</span></code></a> with some parameters.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.max_content_length">
<code class="descname">max_content_length</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.max_content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>the maximum content length. This is forwarded to the form data
parsing function (<code class="xref py py-func docutils literal"><span class="pre">parse_form_data()</span></code>). When set and the
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form" title="werkzeug.wrappers.BaseRequest.form"><code class="xref py py-attr docutils literal"><span class="pre">form</span></code></a> or <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal"><span class="pre">files</span></code></a> attribute is accessed and the
parsing fails because more than the specified value is transmitted
a <a class="reference internal" href="exceptions.html#werkzeug.exceptions.RequestEntityTooLarge" title="werkzeug.exceptions.RequestEntityTooLarge"><code class="xref py py-exc docutils literal"><span class="pre">RequestEntityTooLarge</span></code></a> exception is raised.</p>
<p>Have a look at <a class="reference internal" href="request_data.html#dealing-with-request-data"><span>Dealing with Request Data</span></a> for more details.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.max_form_memory_size">
<code class="descname">max_form_memory_size</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.max_form_memory_size" title="Permalink to this definition">¶</a></dt>
<dd><p>the maximum form field size. This is forwarded to the form data
parsing function (<code class="xref py py-func docutils literal"><span class="pre">parse_form_data()</span></code>). When set and the
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form" title="werkzeug.wrappers.BaseRequest.form"><code class="xref py py-attr docutils literal"><span class="pre">form</span></code></a> or <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal"><span class="pre">files</span></code></a> attribute is accessed and the
data in memory for post data is longer than the specified value a
<a class="reference internal" href="exceptions.html#werkzeug.exceptions.RequestEntityTooLarge" title="werkzeug.exceptions.RequestEntityTooLarge"><code class="xref py py-exc docutils literal"><span class="pre">RequestEntityTooLarge</span></code></a> exception is raised.</p>
<p>Have a look at <a class="reference internal" href="request_data.html#dealing-with-request-data"><span>Dealing with Request Data</span></a> for more details.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.method">
<code class="descname">method</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.method" title="Permalink to this definition">¶</a></dt>
<dd><p>The transmission method. (For example <code class="docutils literal"><span class="pre">'GET'</span></code> or <code class="docutils literal"><span class="pre">'POST'</span></code>).</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.parameter_storage_class">
<code class="descname">parameter_storage_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.parameter_storage_class" title="Permalink to this definition">¶</a></dt>
<dd><p>the class to use for <cite>args</cite> and <cite>form</cite>. The default is an
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal"><span class="pre">ImmutableMultiDict</span></code></a> which supports
multiple values per key. alternatively it makes sense to use an
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableOrderedMultiDict" title="werkzeug.datastructures.ImmutableOrderedMultiDict"><code class="xref py py-class docutils literal"><span class="pre">ImmutableOrderedMultiDict</span></code></a> which
preserves order or a <a class="reference internal" href="datastructures.html#werkzeug.datastructures.ImmutableDict" title="werkzeug.datastructures.ImmutableDict"><code class="xref py py-class docutils literal"><span class="pre">ImmutableDict</span></code></a>
which is the fastest but only remembers the last key. It is also
possible to use mutable structures, but this is not recommended.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<p>alias of <code class="xref py py-class docutils literal"><span class="pre">ImmutableMultiDict</span></code></p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.path">
<code class="descname">path</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.path" title="Permalink to this definition">¶</a></dt>
<dd><p>Requested path as unicode. This works a bit like the regular path
info in the WSGI environment but will always include a leading slash,
even if the URL root is accessed.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.query_string">
<code class="descname">query_string</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.query_string" title="Permalink to this definition">¶</a></dt>
<dd><p>The URL parameters as raw bytestring.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.remote_addr">
<code class="descname">remote_addr</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.remote_addr" title="Permalink to this definition">¶</a></dt>
<dd><p>The remote address of the client.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.remote_user">
<code class="descname">remote_user</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.remote_user" title="Permalink to this definition">¶</a></dt>
<dd><p>If the server supports user authentication, and the script is
protected, this attribute contains the username the user has
authenticated as.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.scheme">
<code class="descname">scheme</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.scheme" title="Permalink to this definition">¶</a></dt>
<dd><p>URL scheme (http or https).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.script_root">
<code class="descname">script_root</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.script_root" title="Permalink to this definition">¶</a></dt>
<dd><p>The root path of the script without the trailing slash.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.stream">
<code class="descname">stream</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.stream" title="Permalink to this definition">¶</a></dt>
<dd><p>The stream to read incoming data from. Unlike <code class="xref py py-attr docutils literal"><span class="pre">input_stream</span></code>
this stream is properly guarded that you can’t accidentally read past
the length of the input. Werkzeug will internally always refer to
this stream to read data which makes it possible to wrap this
object with a stream that does filtering.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.9: </span>This stream is now always available but might be consumed by the
form parser later on. Previously the stream was only set if no
parsing happened.</p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.trusted_hosts">
<code class="descname">trusted_hosts</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="Permalink to this definition">¶</a></dt>
<dd><p>Optionally a list of hosts that is trusted by this request. By default
all hosts are trusted which means that whatever the client sends the
host is will be accepted.</p>
<p>This is the recommended setup as a webserver should manually be set up
to only route correct hosts to the application, and remove the
<cite>X-Forwarded-Host</cite> header if it is not being used (see
<a class="reference internal" href="wsgi.html#werkzeug.wsgi.get_host" title="werkzeug.wsgi.get_host"><code class="xref py py-func docutils literal"><span class="pre">werkzeug.wsgi.get_host()</span></code></a>).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.url">
<code class="descname">url</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.url" title="Permalink to this definition">¶</a></dt>
<dd><p>The reconstructed current URL as IRI.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.url_charset">
<code class="descname">url_charset</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.url_charset" title="Permalink to this definition">¶</a></dt>
<dd><p>The charset that is assumed for URLs. Defaults to the value
of <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.charset" title="werkzeug.wrappers.BaseRequest.charset"><code class="xref py py-attr docutils literal"><span class="pre">charset</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.url_root">
<code class="descname">url_root</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.url_root" title="Permalink to this definition">¶</a></dt>
<dd><p>The full URL root (with hostname), this is the application
root as IRI.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.values">
<code class="descname">values</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.values" title="Permalink to this definition">¶</a></dt>
<dd><p>Combined multi dict for <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.args" title="werkzeug.wrappers.BaseRequest.args"><code class="xref py py-attr docutils literal"><span class="pre">args</span></code></a> and <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form" title="werkzeug.wrappers.BaseRequest.form"><code class="xref py py-attr docutils literal"><span class="pre">form</span></code></a>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.want_form_data_parsed">
<code class="descname">want_form_data_parsed</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.want_form_data_parsed" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the request method carries content. As of
Werkzeug 0.9 this will be the case if a content type is transmitted.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.BaseResponse">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">BaseResponse</code><span class="sig-paren">(</span><em>response=None</em>, <em>status=None</em>, <em>headers=None</em>, <em>mimetype=None</em>, <em>content_type=None</em>, <em>direct_passthrough=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse" title="Permalink to this definition">¶</a></dt>
<dd><p>Base response class. The most important fact about a response object
is that it’s a regular WSGI application. It’s initialized with a couple
of response parameters (headers, body, status code etc.) and will start a
valid WSGI response when called with the environ and start response
callable.</p>
<p>Because it’s a WSGI application itself processing usually ends before the
actual response is sent to the server. This helps debugging systems
because they can catch all the exceptions before responses are started.</p>
<p>Here a small example WSGI application that takes advantage of the
response objects:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">BaseResponse</span> <span class="k">as</span> <span class="n">Response</span>
<span class="k">def</span> <span class="nf">index</span><span class="p">():</span>
<span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s1">'Index page'</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">application</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">):</span>
<span class="n">path</span> <span class="o">=</span> <span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'PATH_INFO'</span><span class="p">)</span> <span class="ow">or</span> <span class="s1">'/'</span>
<span class="k">if</span> <span class="n">path</span> <span class="o">==</span> <span class="s1">'/'</span><span class="p">:</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">index</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">Response</span><span class="p">(</span><span class="s1">'Not Found'</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="mi">404</span><span class="p">)</span>
<span class="k">return</span> <span class="n">response</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">)</span>
</pre></div>
</div>
<p>Like <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></a> which object is lacking a lot of functionality
implemented in mixins. This gives you a better control about the actual
API of your response objects, so you can create subclasses and add custom
functionality. A full featured response object is available as
<a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal"><span class="pre">Response</span></code></a> which implements a couple of useful mixins.</p>
<p>To enforce a new type of already existing responses you can use the
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.force_type" title="werkzeug.wrappers.BaseResponse.force_type"><code class="xref py py-meth docutils literal"><span class="pre">force_type()</span></code></a> method. This is useful if you’re working with different
subclasses of response objects and you want to post process them with a
know interface.</p>
<p>Per default the request object will assume all the text data is <cite>utf-8</cite>
encoded. Please refer to <a class="reference external" href="unicode.txt">the unicode chapter</a> for more
details about customizing the behavior.</p>
<p>Response can be any kind of iterable or string. If it’s a string it’s
considered being an iterable with one item which is the string passed.
Headers can be a list of tuples or a
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal"><span class="pre">Headers</span></code></a> object.</p>
<p>Special note for <cite>mimetype</cite> and <cite>content_type</cite>: For most mime types
<cite>mimetype</cite> and <cite>content_type</cite> work the same, the difference affects
only ‘text’ mimetypes. If the mimetype passed with <cite>mimetype</cite> is a
mimetype starting with <cite>text/</cite>, the charset parameter of the response
object is appended to it. In contrast the <cite>content_type</cite> parameter is
always added as header unmodified.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>the <cite>direct_passthrough</cite> parameter was added.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>response</strong> – a string or response iterable.</li>
<li><strong>status</strong> – a string with a status or an integer with the status code.</li>
<li><strong>headers</strong> – a list of headers or a
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal"><span class="pre">Headers</span></code></a> object.</li>
<li><strong>mimetype</strong> – the mimetype for the request. See notice above.</li>
<li><strong>content_type</strong> – the content type for the request. See notice above.</li>
<li><strong>direct_passthrough</strong> – if set to <cite>True</cite> <a class="reference internal" href="#werkzeug.wrappers.BaseResponse.iter_encoded" title="werkzeug.wrappers.BaseResponse.iter_encoded"><code class="xref py py-meth docutils literal"><span class="pre">iter_encoded()</span></code></a> is not
called before iteration which makes it
possible to pass special iterators though
unchanged (see <code class="xref py py-func docutils literal"><span class="pre">wrap_file()</span></code> for more
details.)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.response">
<code class="descname">response</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.response" title="Permalink to this definition">¶</a></dt>
<dd><p>The application iterator. If constructed from a string this will be a
list, otherwise the object provided as application iterator. (The first
argument passed to <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal"><span class="pre">BaseResponse</span></code></a>)</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal"><span class="pre">Headers</span></code> object representing the response headers.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.status_code">
<code class="descname">status_code</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.status_code" title="Permalink to this definition">¶</a></dt>
<dd><p>The response status as integer.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.direct_passthrough">
<code class="descname">direct_passthrough</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.direct_passthrough" title="Permalink to this definition">¶</a></dt>
<dd><p>If <code class="docutils literal"><span class="pre">direct_passthrough=True</span></code> was passed to the response object or if
this attribute was set to <cite>True</cite> before using the response object as
WSGI application, the wrapped iterator is returned unchanged. This
makes it possible to pass a special <cite>wsgi.file_wrapper</cite> to the response
object. See <code class="xref py py-func docutils literal"><span class="pre">wrap_file()</span></code> for more details.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>environ</em>, <em>start_response</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.__call__" title="Permalink to this definition">¶</a></dt>
<dd><p>Process this response as WSGI application.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>environ</strong> – the WSGI environment.</li>
<li><strong>start_response</strong> – the response callable provided by the WSGI
server.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">an application iterator</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse._ensure_sequence">
<code class="descname">_ensure_sequence</code><span class="sig-paren">(</span><em>mutable=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse._ensure_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>This method can be called by methods that need a sequence. If
<cite>mutable</cite> is true, it will also ensure that the response sequence
is a standard Python list.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.autocorrect_location_header">
<code class="descname">autocorrect_location_header</code><em class="property"> = True</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.autocorrect_location_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Should this response object correct the location header to be RFC
conformant? This is true by default.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.automatically_set_content_length">
<code class="descname">automatically_set_content_length</code><em class="property"> = True</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.automatically_set_content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>Should this response object automatically set the content-length
header if possible? This is true by default.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.calculate_content_length">
<code class="descname">calculate_content_length</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.calculate_content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the content length if available or <cite>None</cite> otherwise.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.call_on_close">
<code class="descname">call_on_close</code><span class="sig-paren">(</span><em>func</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.call_on_close" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a function to the internal list of functions that should
be called as part of closing down the response. Since 0.7 this
function also returns the function that was passed so that this
can be used as a decorator.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.charset">
<code class="descname">charset</code><em class="property"> = 'utf-8'</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>the charset of the response.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the wrapped response if possible. You can also use the object
in a with statement which will automatically close it.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9: </span>Can now be used in a with statement.</p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.data">
<code class="descname">data</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.data" title="Permalink to this definition">¶</a></dt>
<dd><p>A descriptor that calls <a class="reference internal" href="#werkzeug.wrappers.BaseResponse.get_data" title="werkzeug.wrappers.BaseResponse.get_data"><code class="xref py py-meth docutils literal"><span class="pre">get_data()</span></code></a> and <a class="reference internal" href="#werkzeug.wrappers.BaseResponse.set_data" title="werkzeug.wrappers.BaseResponse.set_data"><code class="xref py py-meth docutils literal"><span class="pre">set_data()</span></code></a>. This
should not be used and will eventually get deprecated.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.default_mimetype">
<code class="descname">default_mimetype</code><em class="property"> = 'text/plain'</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.default_mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>the default mimetype if none is provided.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.default_status">
<code class="descname">default_status</code><em class="property"> = 200</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.default_status" title="Permalink to this definition">¶</a></dt>
<dd><p>the default status if none is provided.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.delete_cookie">
<code class="descname">delete_cookie</code><span class="sig-paren">(</span><em>key</em>, <em>path='/'</em>, <em>domain=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.delete_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete a cookie. Fails silently if key doesn’t exist.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – the key (name) of the cookie to be deleted.</li>
<li><strong>path</strong> – if the cookie that should be deleted was limited to a
path, the path has to be defined here.</li>
<li><strong>domain</strong> – if the cookie that should be deleted was limited to a
domain, that domain has to be defined here.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseResponse.force_type">
<em class="property">classmethod </em><code class="descname">force_type</code><span class="sig-paren">(</span><em>response</em>, <em>environ=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.force_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Enforce that the WSGI response is a response object of the current
type. Werkzeug will use the <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal"><span class="pre">BaseResponse</span></code></a> internally in many
situations like the exceptions. If you call <code class="xref py py-meth docutils literal"><span class="pre">get_response()</span></code> on an
exception you will get back a regular <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal"><span class="pre">BaseResponse</span></code></a> object, even
if you are using a custom subclass.</p>
<p>This method can enforce a given response type, and it will also
convert arbitrary WSGI callables into response objects if an environ
is provided:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c1"># convert a Werkzeug response object into an instance of the</span>
<span class="c1"># MyResponseClass subclass.</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">MyResponseClass</span><span class="o">.</span><span class="n">force_type</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="c1"># convert any WSGI application into a response object</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">MyResponseClass</span><span class="o">.</span><span class="n">force_type</span><span class="p">(</span><span class="n">response</span><span class="p">,</span> <span class="n">environ</span><span class="p">)</span>
</pre></div>
</div>
<p>This is especially useful if you want to post-process responses in
the main dispatcher and use functionality provided by your subclass.</p>
<p>Keep in mind that this will modify response objects in place if
possible!</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>response</strong> – a response object or wsgi application.</li>
<li><strong>environ</strong> – a WSGI environment object.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a response object.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.freeze">
<code class="descname">freeze</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.freeze" title="Permalink to this definition">¶</a></dt>
<dd><p>Call this method if you want to make your response object ready for
being pickled. This buffers the generator if there is one. It will
also set the <cite>Content-Length</cite> header to the length of the body.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6: </span>The <cite>Content-Length</cite> header is now set.</p>
</div>
</dd></dl>
<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseResponse.from_app">
<em class="property">classmethod </em><code class="descname">from_app</code><span class="sig-paren">(</span><em>app</em>, <em>environ</em>, <em>buffered=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.from_app" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new response object from an application output. This
works best if you pass it an application that returns a generator all
the time. Sometimes applications may use the <cite>write()</cite> callable
returned by the <cite>start_response</cite> function. This tries to resolve such
edge cases automatically. But if you don’t get the expected output
you should set <cite>buffered</cite> to <cite>True</cite> which enforces buffering.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>app</strong> – the WSGI application to execute.</li>
<li><strong>environ</strong> – the WSGI environment to execute against.</li>
<li><strong>buffered</strong> – set to <cite>True</cite> to enforce buffering.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a response object.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_app_iter">
<code class="descname">get_app_iter</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_app_iter" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the application iterator for the given environ. Depending
on the request method and the current status code the return value
might be an empty response rather than the one from the response.</p>
<p>If the request method is <cite>HEAD</cite> or the status code is in a range
where the HTTP specification requires an empty response, an empty
iterable is returned.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>environ</strong> – the WSGI environment of the request.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a response iterable.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_data">
<code class="descname">get_data</code><span class="sig-paren">(</span><em>as_text=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>The string representation of the request body. Whenever you call
this property the request iterable is encoded and flattened. This
can lead to unwanted behavior if you stream big data.</p>
<p>This behavior can be disabled by setting
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.implicit_sequence_conversion" title="werkzeug.wrappers.BaseResponse.implicit_sequence_conversion"><code class="xref py py-attr docutils literal"><span class="pre">implicit_sequence_conversion</span></code></a> to <cite>False</cite>.</p>
<p>If <cite>as_text</cite> is set to <cite>True</cite> the return value will be a decoded
unicode string.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_wsgi_headers">
<code class="descname">get_wsgi_headers</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_wsgi_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>This is automatically called right before the response is started
and returns headers modified for the given environment. It returns a
copy of the headers from the response with some modifications applied
if necessary.</p>
<p>For example the location header (if present) is joined with the root
URL of the environment. Also the content length is automatically set
to zero here for certain status codes.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6: </span>Previously that function was called <cite>fix_headers</cite> and modified
the response object in place. Also since 0.6, IRIs in location
and content-location headers are handled properly.</p>
<p>Also starting with 0.6, Werkzeug will attempt to set the content
length if it is able to figure it out on its own. This is the
case if all the strings in the response iterable are already
encoded and the iterable is buffered.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>environ</strong> – the WSGI environment of the request.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">returns a new <a class="reference internal" href="datastructures.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal"><span class="pre">Headers</span></code></a>
object.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_wsgi_response">
<code class="descname">get_wsgi_response</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_wsgi_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the final WSGI response as tuple. The first item in
the tuple is the application iterator, the second the status and
the third the list of headers. The response returned is created
specially for the given environment. For example if the request
method in the WSGI environment is <code class="docutils literal"><span class="pre">'HEAD'</span></code> the response will
be empty and only the headers and status code will be present.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>environ</strong> – the WSGI environment of the request.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">an <code class="docutils literal"><span class="pre">(app_iter,</span> <span class="pre">status,</span> <span class="pre">headers)</span></code> tuple.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.implicit_sequence_conversion">
<code class="descname">implicit_sequence_conversion</code><em class="property"> = True</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.implicit_sequence_conversion" title="Permalink to this definition">¶</a></dt>
<dd><p>if set to <cite>False</cite> accessing properties on the response object will
not try to consume the response iterator and convert it into a list.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.2: </span>That attribute was previously called <cite>implicit_seqence_conversion</cite>.
(Notice the typo). If you did use this feature, you have to adapt
your code to the name change.</p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.is_sequence">
<code class="descname">is_sequence</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.is_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>If the iterator is buffered, this property will be <cite>True</cite>. A
response object will consider an iterator to be buffered if the
response attribute is a list or tuple.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.is_streamed">
<code class="descname">is_streamed</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.is_streamed" title="Permalink to this definition">¶</a></dt>
<dd><p>If the response is streamed (the response is not an iterable with
a length information) this property is <cite>True</cite>. In this case streamed
means that there is no information about the number of iterations.
This is usually <cite>True</cite> if a generator is passed to the response object.</p>
<p>This is useful for checking before applying some sort of post
filtering that should not take place for streamed responses.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.iter_encoded">
<code class="descname">iter_encoded</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.iter_encoded" title="Permalink to this definition">¶</a></dt>
<dd><p>Iter the response encoded with the encoding of the response.
If the response object is invoked as WSGI application the return
value of this method is used as application iterator unless
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.direct_passthrough" title="werkzeug.wrappers.BaseResponse.direct_passthrough"><code class="xref py py-attr docutils literal"><span class="pre">direct_passthrough</span></code></a> was activated.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.make_sequence">
<code class="descname">make_sequence</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.make_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the response iterator in a list. By default this happens
automatically if required. If <cite>implicit_sequence_conversion</cite> is
disabled, this method is not automatically called and some properties
might raise exceptions. This also encodes all the items.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.set_cookie">
<code class="descname">set_cookie</code><span class="sig-paren">(</span><em>key</em>, <em>value=''</em>, <em>max_age=None</em>, <em>expires=None</em>, <em>path='/'</em>, <em>domain=None</em>, <em>secure=None</em>, <em>httponly=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.set_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets a cookie. The parameters are the same as in the cookie <cite>Morsel</cite>
object in the Python standard library but it accepts unicode data, too.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – the key (name) of the cookie to be set.</li>
<li><strong>value</strong> – the value of the cookie.</li>
<li><strong>max_age</strong> – should be a number of seconds, or <cite>None</cite> (default) if
the cookie should last only as long as the client’s
browser session.</li>
<li><strong>expires</strong> – should be a <cite>datetime</cite> object or UNIX timestamp.</li>
<li><strong>domain</strong> – if you want to set a cross-domain cookie. For example,
<code class="docutils literal"><span class="pre">domain=".example.com"</span></code> will set a cookie that is
readable by the domain <code class="docutils literal"><span class="pre">www.example.com</span></code>,
<code class="docutils literal"><span class="pre">foo.example.com</span></code> etc. Otherwise, a cookie will only
be readable by the domain that set it.</li>
<li><strong>path</strong> – limits the cookie to a given path, per default it will
span the whole domain.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.set_data">
<code class="descname">set_data</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.set_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets a new string as response. The value set must either by a
unicode or bytestring. If a unicode string is set it’s encoded
automatically to the charset of the response (utf-8 by default).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.status">
<code class="descname">status</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.status" title="Permalink to this definition">¶</a></dt>
<dd><p>The HTTP Status code</p>
</dd></dl>
<dl class="attribute">
<dt>
<code class="descname">status_code</code></dt>
<dd><p>The HTTP Status code as number</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="mixin-classes">
<h2>Mixin Classes<a class="headerlink" href="#mixin-classes" title="Permalink to this headline">¶</a></h2>
<p>Werkzeug also provides helper mixins for various HTTP related functionality
such as etags, cache control, user agents etc. When subclassing you can
mix those classes in to extend the functionality of the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></a>
or <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal"><span class="pre">BaseResponse</span></code></a> object. Here a small example for a request object
that parses accept headers:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">AcceptMixin</span><span class="p">,</span> <span class="n">BaseRequest</span>
<span class="k">class</span> <span class="nc">Request</span><span class="p">(</span><span class="n">BaseRequest</span><span class="p">,</span> <span class="n">AcceptMixin</span><span class="p">):</span>
<span class="k">pass</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal"><span class="pre">Request</span></code></a> and <a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal"><span class="pre">Response</span></code></a> classes subclass the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></a>
and <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal"><span class="pre">BaseResponse</span></code></a> classes and implement all the mixins Werkzeug provides:</p>
<dl class="class">
<dt id="werkzeug.wrappers.Request">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">Request</code><span class="sig-paren">(</span><em>environ</em>, <em>populate_request=True</em>, <em>shallow=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.Request" title="Permalink to this definition">¶</a></dt>
<dd><p>Full featured request object implementing the following mixins:</p>
<ul class="simple">
<li><a class="reference internal" href="#werkzeug.wrappers.AcceptMixin" title="werkzeug.wrappers.AcceptMixin"><code class="xref py py-class docutils literal"><span class="pre">AcceptMixin</span></code></a> for accept header parsing</li>
<li><a class="reference internal" href="#werkzeug.wrappers.ETagRequestMixin" title="werkzeug.wrappers.ETagRequestMixin"><code class="xref py py-class docutils literal"><span class="pre">ETagRequestMixin</span></code></a> for etag and cache control handling</li>
<li><a class="reference internal" href="#werkzeug.wrappers.UserAgentMixin" title="werkzeug.wrappers.UserAgentMixin"><code class="xref py py-class docutils literal"><span class="pre">UserAgentMixin</span></code></a> for user agent introspection</li>
<li><a class="reference internal" href="#werkzeug.wrappers.AuthorizationMixin" title="werkzeug.wrappers.AuthorizationMixin"><code class="xref py py-class docutils literal"><span class="pre">AuthorizationMixin</span></code></a> for http auth handling</li>
<li><a class="reference internal" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin" title="werkzeug.wrappers.CommonRequestDescriptorsMixin"><code class="xref py py-class docutils literal"><span class="pre">CommonRequestDescriptorsMixin</span></code></a> for common headers</li>
</ul>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.Response">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">Response</code><span class="sig-paren">(</span><em>response=None</em>, <em>status=None</em>, <em>headers=None</em>, <em>mimetype=None</em>, <em>content_type=None</em>, <em>direct_passthrough=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.Response" title="Permalink to this definition">¶</a></dt>
<dd><p>Full featured response object implementing the following mixins:</p>
<ul class="simple">
<li><a class="reference internal" href="#werkzeug.wrappers.ETagResponseMixin" title="werkzeug.wrappers.ETagResponseMixin"><code class="xref py py-class docutils literal"><span class="pre">ETagResponseMixin</span></code></a> for etag and cache control handling</li>
<li><a class="reference internal" href="#werkzeug.wrappers.ResponseStreamMixin" title="werkzeug.wrappers.ResponseStreamMixin"><code class="xref py py-class docutils literal"><span class="pre">ResponseStreamMixin</span></code></a> to add support for the <cite>stream</cite> property</li>
<li><a class="reference internal" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin" title="werkzeug.wrappers.CommonResponseDescriptorsMixin"><code class="xref py py-class docutils literal"><span class="pre">CommonResponseDescriptorsMixin</span></code></a> for various HTTP descriptors</li>
<li><a class="reference internal" href="#werkzeug.wrappers.WWWAuthenticateMixin" title="werkzeug.wrappers.WWWAuthenticateMixin"><code class="xref py py-class docutils literal"><span class="pre">WWWAuthenticateMixin</span></code></a> for HTTP authentication support</li>
</ul>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.AcceptMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">AcceptMixin</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for classes with an <code class="xref py py-attr docutils literal"><span class="pre">environ</span></code> attribute
to get all the HTTP accept headers as
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal"><span class="pre">Accept</span></code></a> objects (or subclasses
thereof).</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_charsets">
<code class="descname">accept_charsets</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_charsets" title="Permalink to this definition">¶</a></dt>
<dd><p>List of charsets this client supports as
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.CharsetAccept" title="werkzeug.datastructures.CharsetAccept"><code class="xref py py-class docutils literal"><span class="pre">CharsetAccept</span></code></a> object.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_encodings">
<code class="descname">accept_encodings</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_encodings" title="Permalink to this definition">¶</a></dt>
<dd><p>List of encodings this client accepts. Encodings in a HTTP term
are compression encodings such as gzip. For charsets have a look at
<code class="xref py py-attr docutils literal"><span class="pre">accept_charset</span></code>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_languages">
<code class="descname">accept_languages</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_languages" title="Permalink to this definition">¶</a></dt>
<dd><p>List of languages this client accepts as
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.LanguageAccept" title="werkzeug.datastructures.LanguageAccept"><code class="xref py py-class docutils literal"><span class="pre">LanguageAccept</span></code></a> object.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_mimetypes">
<code class="descname">accept_mimetypes</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_mimetypes" title="Permalink to this definition">¶</a></dt>
<dd><p>List of mimetypes this client supports as
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.MIMEAccept" title="werkzeug.datastructures.MIMEAccept"><code class="xref py py-class docutils literal"><span class="pre">MIMEAccept</span></code></a> object.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.AuthorizationMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">AuthorizationMixin</code><a class="headerlink" href="#werkzeug.wrappers.AuthorizationMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds an <a class="reference internal" href="#werkzeug.wrappers.AuthorizationMixin.authorization" title="werkzeug.wrappers.AuthorizationMixin.authorization"><code class="xref py py-attr docutils literal"><span class="pre">authorization</span></code></a> property that represents the parsed
value of the <cite>Authorization</cite> header as
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.Authorization" title="werkzeug.datastructures.Authorization"><code class="xref py py-class docutils literal"><span class="pre">Authorization</span></code></a> object.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.AuthorizationMixin.authorization">
<code class="descname">authorization</code><a class="headerlink" href="#werkzeug.wrappers.AuthorizationMixin.authorization" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>Authorization</cite> object in parsed form.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.ETagRequestMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">ETagRequestMixin</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Add entity tag and cache descriptors to a request object or object with
a WSGI environment available as <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.environ" title="werkzeug.wrappers.BaseRequest.environ"><code class="xref py py-attr docutils literal"><span class="pre">environ</span></code></a>. This not
only provides access to etags but also to the cache control header.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.cache_control">
<code class="descname">cache_control</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.cache_control" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="datastructures.html#werkzeug.datastructures.RequestCacheControl" title="werkzeug.datastructures.RequestCacheControl"><code class="xref py py-class docutils literal"><span class="pre">RequestCacheControl</span></code></a> object
for the incoming cache control headers.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_match">
<code class="descname">if_match</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_match" title="Permalink to this definition">¶</a></dt>
<dd><p>An object containing all the etags in the <cite>If-Match</cite> header.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="datastructures.html#werkzeug.datastructures.ETags" title="werkzeug.datastructures.ETags"><code class="xref py py-class docutils literal"><span class="pre">ETags</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_modified_since">
<code class="descname">if_modified_since</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_modified_since" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>If-Modified-Since</cite> header as datetime object.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_none_match">
<code class="descname">if_none_match</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_none_match" title="Permalink to this definition">¶</a></dt>
<dd><p>An object containing all the etags in the <cite>If-None-Match</cite> header.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="datastructures.html#werkzeug.datastructures.ETags" title="werkzeug.datastructures.ETags"><code class="xref py py-class docutils literal"><span class="pre">ETags</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_range">
<code class="descname">if_range</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_range" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>If-Range</cite> header.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="datastructures.html#werkzeug.datastructures.IfRange" title="werkzeug.datastructures.IfRange"><code class="xref py py-class docutils literal"><span class="pre">IfRange</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_unmodified_since">
<code class="descname">if_unmodified_since</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_unmodified_since" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>If-Unmodified-Since</cite> header as datetime object.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.range">
<code class="descname">range</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.range" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>Range</cite> header.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="datastructures.html#werkzeug.datastructures.Range" title="werkzeug.datastructures.Range"><code class="xref py py-class docutils literal"><span class="pre">Range</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.ETagResponseMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">ETagResponseMixin</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds extra functionality to a response object for etag and cache
handling. This mixin requires an object with at least a <cite>headers</cite>
object that implements a dict like interface similar to
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal"><span class="pre">Headers</span></code></a>.</p>
<p>If you want the <a class="reference internal" href="#werkzeug.wrappers.ETagResponseMixin.freeze" title="werkzeug.wrappers.ETagResponseMixin.freeze"><code class="xref py py-meth docutils literal"><span class="pre">freeze()</span></code></a> method to automatically add an etag, you
have to mixin this method before the response base class. The default
response class does not do that.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagResponseMixin.accept_ranges">
<code class="descname">accept_ranges</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.accept_ranges" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>Accept-Ranges</cite> header. Even though the name would indicate
that multiple values are supported, it must be one string token only.</p>
<p>The values <code class="docutils literal"><span class="pre">'bytes'</span></code> and <code class="docutils literal"><span class="pre">'none'</span></code> are common.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.add_etag">
<code class="descname">add_etag</code><span class="sig-paren">(</span><em>overwrite=False</em>, <em>weak=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.add_etag" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an etag for the current response if there is none yet.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagResponseMixin.cache_control">
<code class="descname">cache_control</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.cache_control" title="Permalink to this definition">¶</a></dt>
<dd><p>The Cache-Control general-header field is used to specify
directives that MUST be obeyed by all caching mechanisms along the
request/response chain.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagResponseMixin.content_range">
<code class="descname">content_range</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.content_range" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>Content-Range</cite> header as
<a class="reference internal" href="datastructures.html#werkzeug.datastructures.ContentRange" title="werkzeug.datastructures.ContentRange"><code class="xref py py-class docutils literal"><span class="pre">ContentRange</span></code></a> object. Even if the
header is not set it wil provide such an object for easier
manipulation.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.freeze">
<code class="descname">freeze</code><span class="sig-paren">(</span><em>no_etag=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.freeze" title="Permalink to this definition">¶</a></dt>
<dd><p>Call this method if you want to make your response object ready for
pickeling. This buffers the generator if there is one. This also
sets the etag unless <cite>no_etag</cite> is set to <cite>True</cite>.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.get_etag">
<code class="descname">get_etag</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.get_etag" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a tuple in the form <code class="docutils literal"><span class="pre">(etag,</span> <span class="pre">is_weak)</span></code>. If there is no
ETag the return value is <code class="docutils literal"><span class="pre">(None,</span> <span class="pre">None)</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.make_conditional">
<code class="descname">make_conditional</code><span class="sig-paren">(</span><em>request_or_environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.make_conditional" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the response conditional to the request. This method works
best if an etag was defined for the response already. The <cite>add_etag</cite>
method can be used to do that. If called without etag just the date
header is set.</p>
<p>This does nothing if the request method in the request or environ is
anything but GET or HEAD.</p>
<p>It does not remove the body of the response because that’s something
the <code class="xref py py-meth docutils literal"><span class="pre">__call__()</span></code> function does for us automatically.</p>
<p>Returns self so that you can do <code class="docutils literal"><span class="pre">return</span> <span class="pre">resp.make_conditional(req)</span></code>
but modifies the object in-place.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>request_or_environ</strong> – a request object or WSGI environment to be
used to make the response conditional
against.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.set_etag">
<code class="descname">set_etag</code><span class="sig-paren">(</span><em>etag</em>, <em>weak=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.set_etag" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the etag, and override the old one if there was one.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.ResponseStreamMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">ResponseStreamMixin</code><a class="headerlink" href="#werkzeug.wrappers.ResponseStreamMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></a> subclasses. Classes that inherit from
this mixin will automatically get a <a class="reference internal" href="#werkzeug.wrappers.ResponseStreamMixin.stream" title="werkzeug.wrappers.ResponseStreamMixin.stream"><code class="xref py py-attr docutils literal"><span class="pre">stream</span></code></a> property that provides
a write-only interface to the response iterable.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.ResponseStreamMixin.stream">
<code class="descname">stream</code><a class="headerlink" href="#werkzeug.wrappers.ResponseStreamMixin.stream" title="Permalink to this definition">¶</a></dt>
<dd><p>The response iterable as write-only stream.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">CommonRequestDescriptorsMixin</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal"><span class="pre">BaseRequest</span></code></a> subclasses. Request objects that
mix this class in will automatically get descriptors for a couple of
HTTP headers with automatic type conversion.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_encoding">
<code class="descname">content_encoding</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Encoding entity-header field is used as a modifier to the
media-type. When present, its value indicates what additional content
codings have been applied to the entity-body, and thus what decoding
mechanisms must be applied in order to obtain the media-type
referenced by the Content-Type header field.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Length entity-header field indicates the size of the
entity-body in bytes or, in the case of the HEAD method, the size of
the entity-body that would have been sent had the request been a
GET.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_md5">
<code class="descname">content_md5</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_md5" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div>The Content-MD5 entity-header field, as defined in RFC 1864, is an
MD5 digest of the entity-body for the purpose of providing an
end-to-end message integrity check (MIC) of the entity-body. (Note:
a MIC is good for detecting accidental modification of the
entity-body in transit, but is not proof against malicious attacks.)</div></blockquote>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Type entity-header field indicates the media type of
the entity-body sent to the recipient or, in the case of the HEAD
method, the media type that would have been sent had the request
been a GET.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.date">
<code class="descname">date</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.date" title="Permalink to this definition">¶</a></dt>
<dd><p>The Date general-header field represents the date and time at which
the message was originated, having the same semantics as orig-date
in RFC 822.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.max_forwards">
<code class="descname">max_forwards</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.max_forwards" title="Permalink to this definition">¶</a></dt>
<dd><p>The Max-Forwards request-header field provides a mechanism with the
TRACE and OPTIONS methods to limit the number of proxies or gateways
that can forward the request to the next inbound server.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype">
<code class="descname">mimetype</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type" title="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type"><code class="xref py py-attr docutils literal"><span class="pre">content_type</span></code></a> but without parameters (eg, without
charset, type etc.). For example if the content
type is <code class="docutils literal"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the mimetype would be
<code class="docutils literal"><span class="pre">'text/html'</span></code>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype_params">
<code class="descname">mimetype_params</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype_params" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype parameters as dict. For example if the content
type is <code class="docutils literal"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the params would be
<code class="docutils literal"><span class="pre">{'charset':</span> <span class="pre">'utf-8'}</span></code>.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.pragma">
<code class="descname">pragma</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.pragma" title="Permalink to this definition">¶</a></dt>
<dd><p>The Pragma general-header field is used to include
implementation-specific directives that might apply to any recipient
along the request/response chain. All pragma directives specify
optional behavior from the viewpoint of the protocol; however, some
systems MAY require that behavior be consistent with the directives.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.referrer">
<code class="descname">referrer</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.referrer" title="Permalink to this definition">¶</a></dt>
<dd><p>The Referer[sic] request-header field allows the client to specify,
for the server’s benefit, the address (URI) of the resource from which
the Request-URI was obtained (the “referrer”, although the header
field is misspelled).</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">CommonResponseDescriptorsMixin</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal"><span class="pre">BaseResponse</span></code></a> subclasses. Response objects that
mix this class in will automatically get descriptors for a couple of
HTTP headers with automatic type conversion.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.age">
<code class="descname">age</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.age" title="Permalink to this definition">¶</a></dt>
<dd><p>The Age response-header field conveys the sender’s estimate of the
amount of time since the response (or its revalidation) was
generated at the origin server.</p>
<p>Age values are non-negative decimal integers, representing time in
seconds.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.allow">
<code class="descname">allow</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.allow" title="Permalink to this definition">¶</a></dt>
<dd><p>The Allow entity-header field lists the set of methods supported
by the resource identified by the Request-URI. The purpose of this
field is strictly to inform the recipient of valid methods
associated with the resource. An Allow header field MUST be
present in a 405 (Method Not Allowed) response.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_encoding">
<code class="descname">content_encoding</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Encoding entity-header field is used as a modifier to the
media-type. When present, its value indicates what additional content
codings have been applied to the entity-body, and thus what decoding
mechanisms must be applied in order to obtain the media-type
referenced by the Content-Type header field.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_language">
<code class="descname">content_language</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_language" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Language entity-header field describes the natural
language(s) of the intended audience for the enclosed entity. Note
that this might not be equivalent to all the languages used within
the entity-body.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Length entity-header field indicates the size of the
entity-body, in decimal number of OCTETs, sent to the recipient or,
in the case of the HEAD method, the size of the entity-body that would
have been sent had the request been a GET.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_location">
<code class="descname">content_location</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_location" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Location entity-header field MAY be used to supply the
resource location for the entity enclosed in the message when that
entity is accessible from a location separate from the requested
resource’s URI.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_md5">
<code class="descname">content_md5</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_md5" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-MD5 entity-header field, as defined in RFC 1864, is an
MD5 digest of the entity-body for the purpose of providing an
end-to-end message integrity check (MIC) of the entity-body. (Note:
a MIC is good for detecting accidental modification of the
entity-body in transit, but is not proof against malicious attacks.)</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Type entity-header field indicates the media type of the
entity-body sent to the recipient or, in the case of the HEAD method,
the media type that would have been sent had the request been a GET.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.date">
<code class="descname">date</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.date" title="Permalink to this definition">¶</a></dt>
<dd><p>The Date general-header field represents the date and time at which
the message was originated, having the same semantics as orig-date
in RFC 822.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.expires">
<code class="descname">expires</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.expires" title="Permalink to this definition">¶</a></dt>
<dd><p>The Expires entity-header field gives the date/time after which the
response is considered stale. A stale cache entry may not normally be
returned by a cache.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.last_modified">
<code class="descname">last_modified</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.last_modified" title="Permalink to this definition">¶</a></dt>
<dd><p>The Last-Modified entity-header field indicates the date and time at
which the origin server believes the variant was last modified.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.location">
<code class="descname">location</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.location" title="Permalink to this definition">¶</a></dt>
<dd><p>The Location response-header field is used to redirect the recipient
to a location other than the Request-URI for completion of the request
or identification of a new resource.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype">
<code class="descname">mimetype</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype (content type without charset etc.)</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype_params">
<code class="descname">mimetype_params</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype_params" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype parameters as dict. For example if the content
type is <code class="docutils literal"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the params would be
<code class="docutils literal"><span class="pre">{'charset':</span> <span class="pre">'utf-8'}</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.retry_after">
<code class="descname">retry_after</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.retry_after" title="Permalink to this definition">¶</a></dt>
<dd><p>The Retry-After response-header field can be used with a 503 (Service
Unavailable) response to indicate how long the service is expected
to be unavailable to the requesting client.</p>
<p>Time in seconds until expiration or date.</p>
</dd></dl>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.vary">
<code class="descname">vary</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.vary" title="Permalink to this definition">¶</a></dt>
<dd><p>The Vary field value indicates the set of request-header fields that
fully determines, while the response is fresh, whether a cache is
permitted to use the response to reply to a subsequent request
without revalidation.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.WWWAuthenticateMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">WWWAuthenticateMixin</code><a class="headerlink" href="#werkzeug.wrappers.WWWAuthenticateMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a <a class="reference internal" href="#werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate" title="werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate"><code class="xref py py-attr docutils literal"><span class="pre">www_authenticate</span></code></a> property to a response object.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate">
<code class="descname">www_authenticate</code><a class="headerlink" href="#werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>WWW-Authenticate</cite> header in a parsed form.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.wrappers.UserAgentMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">UserAgentMixin</code><a class="headerlink" href="#werkzeug.wrappers.UserAgentMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a <cite>user_agent</cite> attribute to the request object which contains the
parsed user agent of the browser that triggered the request as a
<a class="reference internal" href="utils.html#werkzeug.useragents.UserAgent" title="werkzeug.useragents.UserAgent"><code class="xref py py-class docutils literal"><span class="pre">UserAgent</span></code></a> object.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.UserAgentMixin.user_agent">
<code class="descname">user_agent</code><a class="headerlink" href="#werkzeug.wrappers.UserAgentMixin.user_agent" title="Permalink to this definition">¶</a></dt>
<dd><p>The current user agent.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper"><p class="logo"><a href="index.html">
<img class="logo" src="_static/werkzeug.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Request / Response Objects</a><ul>
<li><a class="reference internal" href="#how-they-work">How they Work</a></li>
<li><a class="reference internal" href="#mutability-and-reusability-of-wrappers">Mutability and Reusability of Wrappers</a></li>
<li><a class="reference internal" href="#base-wrappers">Base Wrappers</a></li>
<li><a class="reference internal" href="#mixin-classes">Mixin Classes</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="debug.html" title="previous chapter">Debugging Applications</a></li>
<li>Next: <a href="routing.html" title="next chapter">URL Routing</a></li>
</ul></li>
</ul>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/wrappers.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
© Copyright 2011, The Werkzeug Team.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
</div>
</body>
</html>
|