mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
796 lines
42 KiB
HTML
796 lines
42 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>HTTP Messages — CodeIgniter 4.0.4 documentation</title>
|
||
|
||
|
||
|
||
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
|
||
<script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
|
||
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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>
|
||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||
<script type="text/javascript" src="../_static/js/citheme.js"></script>
|
||
<script type="text/javascript" src="../_static/js/carbon.js"></script>
|
||
|
||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||
|
||
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Request Class" href="request.html" />
|
||
<link rel="prev" title="Controller Filters" href="filters.html" />
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search" style="background: #DD4814" >
|
||
|
||
|
||
|
||
<a href="../index.html">
|
||
|
||
|
||
|
||
|
||
<img src="../_static/ci-logo-text.png" class="logo" alt="Logo"/>
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/requirements.html">Server Requirements</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/credits.html">Credits</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/psr.html">PSR Compliance</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../installation/installing_manual.html">Manual Installation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../installation/installing_composer.html">Composer Installation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../installation/running.html">Running Your App</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../installation/repositories.html">CodeIgniter Repositories</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Build Your First Application</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../concepts/index.html">CodeIgniter4 Overview</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/structure.html">Application Structure</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/mvc.html">Models, Views, and Controllers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/autoloader.html">Autoloading Files</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/services.html">Services</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/http.html">Working With HTTP Requests</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/security.html">Security Guidelines</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/configuration.html">Configuration</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helper Functions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Global Functions and Constants</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/logging.html">Logging Information</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Web Page Caching</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/ajax.html">AJAX Requests</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/modules.html">Code Modules</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul class="current">
|
||
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Controllers and Routing</a><ul class="current">
|
||
<li class="toctree-l2"><a class="reference internal" href="controllers.html">Controllers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="routing.html">URI Routing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="filters.html">Controller Filters</a></li>
|
||
<li class="toctree-l2 current"><a class="current reference internal" href="#">HTTP Messages</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="request.html">Request Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="incomingrequest.html">IncomingRequest Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="content_negotiation.html">Content Negotiation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="methodspoofing.html">HTTP Method Spoofing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="restful.html">RESTful Resource Handling</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../outgoing/index.html">Building Responses</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/views.html">Views</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_cells.html">View Cells</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_renderer.html">View Renderer</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_layouts.html">View Layouts</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_parser.html">View Parser</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/table.html">HTML Table Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/response.html">HTTP Responses</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/api_responses.html">API Response Trait</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/localization.html">Localization</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Working With Databases</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/events.html">Database Events</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../models/index.html">Modeling Data</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../models/model.html">Using CodeIgniter's Model</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../models/entities.html">Using Entity Classes</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../dbmgmt/index.html">Managing Databases</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/forge.html">Database Manipulation with Database Forge</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/migration.html">Database Migrations</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/seeds.html">Database Seeding</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Library Reference</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/curlrequest.html">CURLRequest Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Service</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/files.html">Working with Files</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/honeypot.html">Honeypot Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/images.html">Image Manipulation Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/throttler.html">Throttler</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/time.html">Dates and Times</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/uploaded_files.html">Working with Uploaded Files</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">Working with URIs</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/validation.html">Validation</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/filesystem_helper.html">Filesystem Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/test_helper.html">Test Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html">Testing</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/overview.html">Getting Started</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/database.html">Database</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/fabricator.html">Generating Data</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/controllers.html">Controller Testing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/feature.html">HTTP Testing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/benchmark.html">Benchmarking</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/debugging.html">Debugging Your Application</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../cli/index.html">Command Line Usage</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli.html">Running via the Command Line</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_commands.html">Custom CLI Commands</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_library.html">CLI Library</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_request.html">CLIRequest Class</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../extending/index.html">Extending CodeIgniter</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/core_classes.html">Creating Core System Classes</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/common.html">Replacing Common Functions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/events.html">Events</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/basecontroller.html">Extending the Controller</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/authentication.html">Authentication</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/contributing.html">Contributing to CodeIgniter</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" aria-label="top navigation">
|
||
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="../index.html">CodeIgniter</a>
|
||
|
||
</nav>
|
||
|
||
|
||
<div class="wy-nav-content">
|
||
|
||
<div class="rst-content">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
|
||
<ul class="wy-breadcrumbs">
|
||
|
||
<li><a href="../index.html" class="icon icon-home"></a> »</li>
|
||
|
||
<li><a href="index.html">Controllers and Routing</a> »</li>
|
||
|
||
<li>HTTP Messages</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="http-messages">
|
||
<h1>HTTP Messages<a class="headerlink" href="#http-messages" title="Permalink to this headline">¶</a></h1>
|
||
<p>The Message class provides an interface to the portions of an HTTP message that are common to both
|
||
requests and responses, including the message body, protocol version, utilities for working with
|
||
the headers, and methods for handling content negotiation.</p>
|
||
<p>This class is the parent class that both the <a class="reference internal" href="request.html"><span class="doc">Request Class</span></a> and the
|
||
<a class="reference internal" href="../outgoing/response.html"><span class="doc">Response Class</span></a> extend from. As such, some methods, such as the content
|
||
negotiation methods, may apply only to a request or response, and not the other one, but they have
|
||
been included here to keep the header methods together.</p>
|
||
<div class="section" id="what-is-content-negotiation">
|
||
<h2>What is Content Negotiation?<a class="headerlink" href="#what-is-content-negotiation" title="Permalink to this headline">¶</a></h2>
|
||
<p>At it’s heart Content Negotiation is simply a part of the HTTP specification that allows a single
|
||
resource to serve more than one type of content, allowing the clients to request the type of
|
||
data that works best for them.</p>
|
||
<p>A classic example of this is a browser that cannot display PNG files can request only GIF or
|
||
JPEG images. When the getServer receives the request, it looks at the available file types the client
|
||
is requesting and selects the best match from the image formats that it supports, in this case
|
||
likely choosing a JPEG image to return.</p>
|
||
<p>This same negotiation can happen with four types of data:</p>
|
||
<ul class="simple">
|
||
<li><strong>Media/Document Type</strong> - this could be image format, or HTML vs. XML or JSON.</li>
|
||
<li><strong>Character Set</strong> - The character set the returned document should be set in. Typically is UTF-8.</li>
|
||
<li><strong>Document Encoding</strong> - Typically the type of compression used on the results.</li>
|
||
<li><strong>Document Language</strong> - For sites that support multiple languages, this helps determine which to return.</li>
|
||
</ul>
|
||
<div class="section" id="class-reference">
|
||
<h3>Class Reference<a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h3>
|
||
<dl class="class">
|
||
<dt>
|
||
<code class="descname">CodeIgniter\HTTP\Message</code></dt>
|
||
<dd><dl class="method">
|
||
<dt id="getBody">
|
||
<code class="descname">getBody</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getBody" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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">The current message body</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">mixed</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Returns the current message body, if any has been set. If not body exists, returns null:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$message</span><span class="o">-></span><span class="na">getBody</span><span class="p">();</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="setBody">
|
||
<code class="descname">setBody</code><span class="sig-paren">(</span><em>$data</em><span class="sig-paren">)</span><a class="headerlink" href="#setBody" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$data</strong> (<em>mixed</em>) – The body of the message.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the Message|Response instance to allow methods to be chained together.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message|CodeIgniter\HTTP\Response</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Sets the body of the current request.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="appendBody">
|
||
<code class="descname">appendBody</code><span class="sig-paren">(</span><em>$data</em><span class="sig-paren">)</span><a class="headerlink" href="#appendBody" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$data</strong> (<em>mixed</em>) – The body of the message.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the Message|Response instance to allow methods to be chained together.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message|CodeIgniter\HTTP\Response</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Appends data to the body of the current request.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="populateHeaders">
|
||
<code class="descname">populateHeaders</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#populateHeaders" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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">void</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Scans and parses the headers found in the SERVER data and stores it for later access.
|
||
This is used by the <a class="reference internal" href="incomingrequest.html"><span class="doc">IncomingRequest Class</span></a> to make
|
||
the current request’s headers available.</p>
|
||
<p>The headers are any SERVER data that starts with <code class="docutils literal notranslate"><span class="pre">HTTP_</span></code>, like <code class="docutils literal notranslate"><span class="pre">HTTP_HOST</span></code>. Each message
|
||
is converted from it’s standard uppercase and underscore format to a ucwords and dash format.
|
||
The preceding <code class="docutils literal notranslate"><span class="pre">HTTP_</span></code> is removed from the string. So <code class="docutils literal notranslate"><span class="pre">HTTP_ACCEPT_LANGUAGE</span></code> becomes
|
||
<code class="docutils literal notranslate"><span class="pre">Accept-Language</span></code>.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="getHeaders">
|
||
<code class="descname">getHeaders</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getHeaders" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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">An array of all of the headers found.</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Returns an array of all headers found or previously set.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="getHeader">
|
||
<code class="descname">getHeader</code><span class="sig-paren">(</span><em>$name</em><span class="sig-paren">)</span><a class="headerlink" href="#getHeader" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header you want to retrieve the value of.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Header|array</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Allows you to retrieve the current value of a single message header. <code class="docutils literal notranslate"><span class="pre">$name</span></code> is the case-insensitive header name.
|
||
While the header is converted internally as described above, you can access the header with any type of case:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="c1">// These are all the same:</span>
|
||
<span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'HOST'</span><span class="p">);</span>
|
||
<span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'Host'</span><span class="p">);</span>
|
||
<span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'host'</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>If the header has multiple values, <code class="docutils literal notranslate"><span class="pre">getValue()</span></code> will return as an array of values. You can use the <code class="docutils literal notranslate"><span class="pre">getValueLine()</span></code>
|
||
method to retrieve the values as a string:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'Accept-Language'</span><span class="p">);</span>
|
||
|
||
<span class="c1">// Outputs something like:</span>
|
||
<span class="s1">'Accept-Language: en,en-US'</span>
|
||
|
||
<span class="k">echo</span> <span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'Accept-Language'</span><span class="p">)</span><span class="o">-></span><span class="na">getValue</span><span class="p">();</span>
|
||
|
||
<span class="c1">// Outputs something like:</span>
|
||
<span class="p">[</span>
|
||
<span class="s1">'en'</span><span class="p">,</span>
|
||
<span class="s1">'en-US'</span>
|
||
<span class="p">]</span>
|
||
|
||
<span class="k">echo</span> <span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'Accept-Language'</span><span class="p">)</span><span class="o">-></span><span class="na">getValueLine</span><span class="p">();</span>
|
||
|
||
<span class="c1">// Outputs something like:</span>
|
||
<span class="s1">'en,en-US'</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>You can filter the header by passing a filter value in as the second parameter:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nv">$message</span><span class="o">-></span><span class="na">getHeader</span><span class="p">(</span><span class="s1">'Document-URI'</span><span class="p">,</span> <span class="nx">FILTER_SANITIZE_URL</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="hasHeader">
|
||
<code class="descname">hasHeader</code><span class="sig-paren">(</span><em>$name</em><span class="sig-paren">)</span><a class="headerlink" href="#hasHeader" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header you want to see if it exists.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Returns TRUE if it exists, FALSE otherwise.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="getHeaderLine">
|
||
<code class="descname">getHeaderLine</code><span class="sig-paren">(</span><em>$name</em><span class="sig-paren">)</span><a class="headerlink" href="#getHeaderLine" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header to retrieve.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A string representing the header value.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Returns the value(s) of the header as a string. This method allows you to easily get a string representation
|
||
of the header values when the header has multiple values. The values are appropriately joined:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$message</span><span class="o">-></span><span class="na">getHeaderLine</span><span class="p">(</span><span class="s1">'Accept-Language'</span><span class="p">);</span>
|
||
|
||
<span class="c1">// Outputs:</span>
|
||
<span class="nx">en</span><span class="p">,</span> <span class="nx">en</span><span class="o">-</span><span class="nx">US</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="setHeader">
|
||
<code class="descname">setHeader</code><span class="sig-paren">(</span><em>$name</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#setHeader" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header to set the value for.</li>
|
||
<li><strong>$value</strong> (<em>mixed</em>) – The value to set the header to.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The current Message|Response instance</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message|CodeIgniter\HTTP\Response</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Sets the value of a single header. <code class="docutils literal notranslate"><span class="pre">$name</span></code> is the case-insensitive name of the header. If the header
|
||
doesn’t already exist in the collection, it will be created. The <code class="docutils literal notranslate"><span class="pre">$value</span></code> can be either a string
|
||
or an array of strings:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nv">$message</span><span class="o">-></span><span class="na">setHeader</span><span class="p">(</span><span class="s1">'Host'</span><span class="p">,</span> <span class="s1">'codeigniter.com'</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="removeHeader">
|
||
<code class="descname">removeHeader</code><span class="sig-paren">(</span><em>$name</em><span class="sig-paren">)</span><a class="headerlink" href="#removeHeader" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header to remove.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The current message instance</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Removes the header from the Message. <code class="docutils literal notranslate"><span class="pre">$name</span></code> is the case-insensitive name of the header:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nv">$message</span><span class="o">-></span><span class="na">removeHeader</span><span class="p">(</span><span class="s1">'Host'</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="appendHeader">
|
||
<code class="descname">appendHeader</code><span class="sig-paren">(</span><em>$name</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#appendHeader" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header to modify</li>
|
||
<li><strong>$value</strong> (<em>string</em>) – The value to add to the header.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The current message instance</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Adds a value to an existing header. The header must already be an array of values instead of a single string.
|
||
If it is a string then a LogicException will be thrown.</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nv">$message</span><span class="o">-></span><span class="na">appendHeader</span><span class="p">(</span><span class="s1">'Accept-Language'</span><span class="p">,</span> <span class="s1">'en-US; q=0.8'</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="prependHeader">
|
||
<code class="descname">prependHeader</code><span class="sig-paren">(</span><em>$name</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#prependHeader" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$name</strong> (<em>string</em>) – The name of the header to modify</li>
|
||
<li><strong>$value</strong> (<em>string</em>) – The value to prepend to the header.</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The current message instance</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Prepends a value to an existing header. The header must already be an array of values instead of a single string.
|
||
If it is a string then a LogicException will be thrown.</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nv">$message</span><span class="o">-></span><span class="na">prependHeader</span><span class="p">(</span><span class="s1">'Accept-Language'</span><span class="p">,</span> <span class="s1">'en,'</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="getProtocolVersion">
|
||
<code class="descname">getProtocolVersion</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getProtocolVersion" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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">The current HTTP protocol version</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Returns the message’s current HTTP protocol. If none has been set, will return <code class="docutils literal notranslate"><span class="pre">null</span></code>.
|
||
Acceptable values are <code class="docutils literal notranslate"><span class="pre">1.0</span></code>, <code class="docutils literal notranslate"><span class="pre">1.1</span></code> and <code class="docutils literal notranslate"><span class="pre">2.0</span></code>.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="setProtocolVersion">
|
||
<code class="descname">setProtocolVersion</code><span class="sig-paren">(</span><em>$version</em><span class="sig-paren">)</span><a class="headerlink" href="#setProtocolVersion" title="Permalink to this definition">¶</a></dt>
|
||
<dd><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>$version</strong> (<em>string</em>) – The HTTP protocol version</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The current message instance</p>
|
||
</td>
|
||
</tr>
|
||
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">CodeIgniter\HTTP\Message</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Sets the HTTP protocol version this Message uses. Valid values are <code class="docutils literal notranslate"><span class="pre">1.0</span></code>, <code class="docutils literal notranslate"><span class="pre">1.1</span></code> and <code class="docutils literal notranslate"><span class="pre">2.0</span></code>:</p>
|
||
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nv">$message</span><span class="o">-></span><span class="na">setProtocolVersion</span><span class="p">(</span><span class="s1">'1.1'</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
||
<a href="request.html" class="btn btn-neutral float-right" title="Request Class" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
||
|
||
<a href="filters.html" class="btn btn-neutral float-left" title="Controller Filters" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||
|
||
</div>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
|
||
© Copyright 2019-2020 CodeIgniter Foundation
|
||
<span class="lastupdated">
|
||
Last updated on Jul 20, 2020.
|
||
</span>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
|
||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
|
||
|
||
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
|
||
|
||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(false);
|
||
});
|
||
</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |