HttpSetResponseCode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 16: Line 16:
==Example==
==Example==
<section name="Server/HTTP" class="http" show="true">
<section name="Server/HTTP" class="http" show="true">
This example displays a 'Page not found' error message and the response code 404.
This example displays a 'Page not found' error message and the response code 404. The location of the [[setResponseCode]] call is unimportant - it can be placed anywhere in the document.
<syntaxhighlight lang="lua">[html]<html>
<syntaxhighlight lang="lua">[html]<html>
<h1>Page not found!</h1>
<h1>Page not found!</h1>
<* setResponseCode ( 404 ) *>
<* setResponseCode ( 404 ) *>
</syntaxhighlight>
</html></syntaxhighlight>


</section>
</section>
[[Category:Needs Example]]


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

Revision as of 17:21, 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 setResponseCode call is unimportant - it can be placed anywhere in the document.

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

See Also

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