HttpSetResponseCode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{HTTP function}} This function sets the HTTP status code that will be sent for the current HTML page. ==Syntax== <syntaxhighlight lang="lua"> bool httpSetResponseCode ( int code ) </syntaxhighlight> ==Re...)
 
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 9: Line 9:


==Required Arguments==
==Required Arguments==
'''code:''' the HTTP status code to be set.
*'''code:''' the HTTP status code to be set.


===Returns===
===Returns===
Line 15: Line 15:


==Example==
==Example==
[[Category:Needs Example]]
<section name="Server/HTTP" class="http" show="true">
This example displays a 'Page not found' error message and the response code 404. The location of the [[httpSetResponseCode]] call is unimportant - it can be placed anywhere in the document.
<syntaxhighlight lang="lua">[html]<html>
<h1>Page not found!</h1>
<* httpSetResponseCode ( 404 ) *>
</html></syntaxhighlight>
 
</section>


==See Also==
==See Also==
{{HTTP functions}}
{{HTTP functions}}

Latest revision as of 17:24, 27 October 2007

This function sets the HTTP status code that will be sent for the current HTML page.

Syntax

bool httpSetResponseCode ( int code )

Required Arguments

  • code: the HTTP status code to be set.

Returns

Returns true if the code was set successfully, false otherwise.

Example

Click to collapse [-]
Server/HTTP

This example displays a 'Page not found' error message and the response code 404. The location of the httpSetResponseCode call is unimportant - it can be placed anywhere in the document.

[html]<html>
<h1>Page not found!</h1>
<* httpSetResponseCode ( 404 ) *>
</html>

See Also

These functions can only be used from within lua blocks in HTML pages hosted by the server