blob: 43609a2712dd44168b7454a12aae705ca573db09 [file] [log] [blame]
<!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/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>libwebsockets: HTTP File transfer</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">libwebsockets
</div>
<div id="projectbrief">Lightweight C library for HTML5 websockets</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li class="current"><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__httpft.html','');});
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">HTTP File transfer<div class="ingroups"><a class="el" href="group__http.html">HTTP</a></div></div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gab4da87a4800413f15e7aba649fb1d77c"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__httpft.html#gab4da87a4800413f15e7aba649fb1d77c">lws_get_mimetype</a> (const char *file, const struct <a class="el" href="structlws__http__mount.html">lws_http_mount</a> *m)</td></tr>
<tr class="separator:gab4da87a4800413f15e7aba649fb1d77c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab393a06d3d2722af4c3f8b06842c80d7"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__httpft.html#gab393a06d3d2722af4c3f8b06842c80d7">lws_serve_http_file</a> (struct lws *wsi, const char *file, const char *content_type, const char *other_headers, int other_headers_len)</td></tr>
<tr class="separator:gab393a06d3d2722af4c3f8b06842c80d7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga29e1123f6d56cd777b3e5bf9ca40f9e5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga29e1123f6d56cd777b3e5bf9ca40f9e5"></a>
LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><b>lws_serve_http_file_fragment</b> (struct lws *wsi)</td></tr>
<tr class="separator:ga29e1123f6d56cd777b3e5bf9ca40f9e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>APIs for sending local files in response to HTTP requests </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="gab4da87a4800413f15e7aba649fb1d77c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">LWS_VISIBLE LWS_EXTERN const char* lws_get_mimetype </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>file</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct <a class="el" href="structlws__http__mount.html">lws_http_mount</a> *&#160;</td>
<td class="paramname"><em>m</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__httpft.html#gab4da87a4800413f15e7aba649fb1d77c">lws_get_mimetype()</a> - Determine mimetype to use from filename</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">file</td><td>filename </td></tr>
<tr><td class="paramname">m</td><td>NULL, or mount context</td></tr>
</table>
</dd>
</dl>
<p>This uses a canned list of known filetypes first, if no match and m is non-NULL, then tries a list of per-mount file suffix to mimtype mappings.</p>
<p>Returns either NULL or a pointer to the mimetype matching the file. </p>
</div>
</div>
<a class="anchor" id="gab393a06d3d2722af4c3f8b06842c80d7"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">LWS_VISIBLE LWS_EXTERN int lws_serve_http_file </td>
<td>(</td>
<td class="paramtype">struct lws *&#160;</td>
<td class="paramname"><em>wsi</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>file</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>content_type</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>other_headers</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>other_headers_len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__httpft.html#gab393a06d3d2722af4c3f8b06842c80d7">lws_serve_http_file()</a> - Send a file back to the client using http </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">wsi</td><td>Websocket instance (available from user callback) </td></tr>
<tr><td class="paramname">file</td><td>The file to issue over http </td></tr>
<tr><td class="paramname">content_type</td><td>The http content type, eg, text/html </td></tr>
<tr><td class="paramname">other_headers</td><td>NULL or pointer to header string </td></tr>
<tr><td class="paramname">other_headers_len</td><td>length of the other headers if non-NULL <pre class="fragment"> This function is intended to be called from the callback in response
to http requests from the client. It allows the callback to issue
local files down the http link in a single step.
Returning &lt;0 indicates error and the wsi should be closed. Returning
&gt;0 indicates the file was completely sent and
lws_http_transaction_completed() called on the wsi (and close if != 0)
==0 indicates the file transfer is started and needs more service later,
the wsi should be left alone.</pre> </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
</ul>
</div>
</body>
</html>