Difference between revisions of "Ns return"

From AOLserver Wiki
Jump to navigation Jump to search
(add internal links)
(formatting tweaks)
Line 1: Line 1:
Name
+
<manpage>ns_return</manpage>
 +
 
 +
== NAME ==
 +
 
 
ns_connsendfp, ns_respond, ns_return, ns_returnadminnotice, ns_returnbadrequest, ns_returnerror, ns_returnfile, ns_returnforbidden, ns_returnfp, ns_returnnotfound, ns_returnnotice, ns_returnredirect, ns_returnunauthorized, ns_write - commands
 
ns_connsendfp, ns_respond, ns_return, ns_returnadminnotice, ns_returnbadrequest, ns_returnerror, ns_returnfile, ns_returnforbidden, ns_returnfp, ns_returnnotfound, ns_returnnotice, ns_returnredirect, ns_returnunauthorized, ns_write - commands
Synopsis
 
[[ns_connsendfp]] fp len
 
  
[[ns_respond]]
+
== SYNOPSIS ==
 +
 
 +
: '''[[ns_connsendfp]]''' ''fp len''
 +
: '''[[ns_respond]]'''
 +
: '''ns_return''' ''status type string''
 +
: '''[[ns_returnadminnotice]]''' ''status msg ?longmsg?''
 +
: '''[[ns_returnbadrequest]]''' ''reason''
 +
: '''[[ns_returnerror]]''' ''status msg''
 +
: '''[[ns_returnfile]]''' ''status type filename''
 +
: '''[[ns_returnforbidden]]'''
 +
: '''[[ns_returnfp]]''' ''status type fileid len''
 +
: '''[[ns_returnnotfound]]'''
 +
: '''[[ns_returnnotice]]''' ''status msg ?longmsg?''
 +
: '''[[ns_returnredirect]]''' ''location''
 +
: '''[[ns_returnunauthorized]]'''
 +
: '''[[ns_write]]''' ''string''
 +
 
 +
== DESCRIPTION ==
 +
 
 +
These procedures provide a simple interface for returning information to the client. They build HTTP/1.0 headers and send the appropriate data out the socket to the client. The script does not end at the time ns_return* is invoked so you can continue processing data after the client has gotten the data and closed the socket.
  
ns_return status type string
+
''type'' should be a MIME type (see [[ns_guesstype]] for a list). ''status'' is a three-digit number fitting the pattern below:
  
[[ns_returnadminnotice]] status msg ?longmsg?
+
: 1xx Informational - Not used, but reserved for future use.
 +
: 2xx Success - The action was successfully received, understood, and accepted.
 +
: 3xx Redirection - Further action must be taken in order to complete the request.
 +
: 4xx Client Error - The request contains bad syntax or cannot be fulfilled.
 +
: 5xx Server Error - The server failed to fulfill an apparently valid request.
  
[[ns_returnbadrequest]] reason
+
Some common status values and their meanings are:
  
[[ns_returnerror]] status msg
+
: 201 Created
 +
: 202 Accepted
 +
: 203 Provisional Information
 +
: 204 No Content
 +
: 300 Multiple Choices
 +
: 301 Moved Permanently
 +
: 302 Moved Temporarily
 +
: 303 Method
 +
: 304 Not Modified
 +
: 401 Unauthorized
 +
: 402 Payment Required
 +
: 403 Forbidden
 +
: 404 Not Found
 +
: 405 Method Not Allowed
 +
: 406 None Acceptable
 +
: 407 Proxy Authentication Required
 +
: 408 Request Time-out
 +
: 409 Conflict
 +
: 410 Gone
 +
: 501 Not Implemented
 +
: 502 Bad Gateway
 +
: 503 Service Unavailable
 +
: 504 Gateway Time-out
  
[[ns_returnfile]] status type filename
+
; ns_connsendfp
 +
: This function writes len bytes of the specified channel or file to the conn.
  
[[ns_returnforbidden]]
+
; ns_return
 +
: Sends back both the headers and the string.
  
[[ns_returnfp]] status type fileid len
+
; ns_returnadminnotice
 +
: Wraps the text msg and longmsg in some html, appends a line with a link to "mailto:serveradministrator" based on the virtual server parameter "WebMaster".
  
[[ns_returnnotfound]]
+
; ns_returnbadrequest
 +
: Returns a 400 status code and a formatted HTML message containing the reason text.
  
[[ns_returnnotice]] status msg ?longmsg?
+
; ns_returnerror
 +
: Wraps the text msg in some html and returns that to the client.
  
[[ns_returnredirect]] location
+
; ns_returnfile
 +
: Sends back the headers and the contents of the file.
  
[[ns_returnunauthorized]]
+
; ns_returnforbidden
 +
: Returns a 403 status code.
  
[[ns_write]] string
+
; ns_returnfp
 +
: First sends the appropriate headers. Next, it writes out the contents of file from the current file position until the end of the file.
  
Description
+
; ns_returnnotfound
 +
: Returns a 404 status code.
  
These procedures provide a simple interface for returning information to the client. They build HTTP/1.0 headers and send the appropriate data out the socket to the client. The script does not end at the time ns_return* is invoked so you can continue processing data after the client has gotten the data and closed the socket.
+
; ns_returnnotice
 +
: Wraps the text msg and longmsg in some html and returns that to the client.
 +
 
 +
; ns_returnredirect
 +
: Returns a redirect to the passed in location
  
type should be a MIME type (see ns_guesstype manual page for a list). status is a three-digit number fitting the pattern below:
+
; ns_returnunauthorized
 +
: Returns a 401 status code
  
1xx Informational - Not used, but reserved for future use.
+
; ns_write
2xx Success - The action was successfully received, understood, and accepted.
+
: Writes the string out the connection. You can use it instead of the ns_return or ns_respond functions to build HTTP responses. AOLserver will not include the usual headers on the output data. The script does not end at the time ns_write* is invoked so you can continue processing data after the client has gotten the data and closed the socket.
3xx Redirection - Further action must be taken in order to complete the request.
 
4xx Client Error - The request contains bad syntax or cannot be fulfilled.
 
5xx Server Error - The server failed to fulfill an apparently valid request.
 
Some common status values and their meanings are:
 
  
201 Created
+
== SEE ALSO ==
202 Accepted
 
203 Provisional Information
 
204 No Content
 
300 Multiple Choices
 
301 Moved Permanently
 
302 Moved Temporarily
 
303 Method
 
304 Not Modified
 
401 Unauthorized
 
402 Payment Required
 
403 Forbidden
 
404 Not Found
 
405 Method Not Allowed
 
406 None Acceptable
 
407 Proxy Authentication Required
 
408 Request Time-out
 
409 Conflict
 
410 Gone
 
501 Not Implemented
 
502 Bad Gateway
 
503 Service Unavailable
 
504 Gateway Time-out
 
ns_connsendfp
 
This function writes len bytes of the specified channel or file to the conn.
 
ns_return
 
Sends back both the headers and the string.
 
ns_returnadminnotice
 
Wraps the text msg and longmsg in some html, appends a line with a link to "mailto:serveradministrator" based on the virtual server parameter "WebMaster".
 
ns_returnbadrequest
 
Returns a 400 status code and a formatted HTML message containing the reason text.
 
ns_returnerror
 
Wraps the text msg in some html and returns that to the client.
 
ns_returnfile
 
Sends back the headers and the contents of the file.
 
ns_returnforbidden
 
Returns a 403 status code.
 
ns_returnfp
 
First sends the appropriate headers. Next, it writes out the contents of file from the current file position until the end of the file.
 
ns_returnnotfound
 
Returns a 404 status code.
 
ns_returnnotice
 
Wraps teh text msg and longmsg in some html and returns that to the client.
 
ns_returnredirect
 
Returns a redirect to the passed in location
 
ns_returnunauthorized
 
Returns a 401 status code
 
ns_write
 
Writes the string out the connection. You can use it instead of the ns_return or ns_respond functions to build HTTP responses. AOLserver will not include the usual headers on the output data. The script does not end at the time ns_write* is invoked so you can continue processing data after the client has gotten the data and closed the socket.
 
  
See Also
+
: [[ns_connsendfp]], [[ns_respond]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnredirect]], [[ns_returnunauthorized]], [[ns_write]]
  
ns_respond(n) , ns_writefp(n)
+
__NOTOC__
 +
[[Category:Documentation]]
 +
[[Category:Core Tcl API]]

Revision as of 20:20, 19 April 2006

<manpage>ns_return</manpage>

NAME

ns_connsendfp, ns_respond, ns_return, ns_returnadminnotice, ns_returnbadrequest, ns_returnerror, ns_returnfile, ns_returnforbidden, ns_returnfp, ns_returnnotfound, ns_returnnotice, ns_returnredirect, ns_returnunauthorized, ns_write - commands

SYNOPSIS

ns_connsendfp fp len
ns_respond
ns_return status type string
ns_returnadminnotice status msg ?longmsg?
ns_returnbadrequest reason
ns_returnerror status msg
ns_returnfile status type filename
ns_returnforbidden
ns_returnfp status type fileid len
ns_returnnotfound
ns_returnnotice status msg ?longmsg?
ns_returnredirect location
ns_returnunauthorized
ns_write string

DESCRIPTION

These procedures provide a simple interface for returning information to the client. They build HTTP/1.0 headers and send the appropriate data out the socket to the client. The script does not end at the time ns_return* is invoked so you can continue processing data after the client has gotten the data and closed the socket.

type should be a MIME type (see ns_guesstype for a list). status is a three-digit number fitting the pattern below:

1xx Informational - Not used, but reserved for future use.
2xx Success - The action was successfully received, understood, and accepted.
3xx Redirection - Further action must be taken in order to complete the request.
4xx Client Error - The request contains bad syntax or cannot be fulfilled.
5xx Server Error - The server failed to fulfill an apparently valid request.

Some common status values and their meanings are:

201 Created
202 Accepted
203 Provisional Information
204 No Content
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 Method
304 Not Modified
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 None Acceptable
407 Proxy Authentication Required
408 Request Time-out
409 Conflict
410 Gone
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Time-out
ns_connsendfp
This function writes len bytes of the specified channel or file to the conn.
ns_return
Sends back both the headers and the string.
ns_returnadminnotice
Wraps the text msg and longmsg in some html, appends a line with a link to "mailto:serveradministrator" based on the virtual server parameter "WebMaster".
ns_returnbadrequest
Returns a 400 status code and a formatted HTML message containing the reason text.
ns_returnerror
Wraps the text msg in some html and returns that to the client.
ns_returnfile
Sends back the headers and the contents of the file.
ns_returnforbidden
Returns a 403 status code.
ns_returnfp
First sends the appropriate headers. Next, it writes out the contents of file from the current file position until the end of the file.
ns_returnnotfound
Returns a 404 status code.
ns_returnnotice
Wraps the text msg and longmsg in some html and returns that to the client.
ns_returnredirect
Returns a redirect to the passed in location
ns_returnunauthorized
Returns a 401 status code
ns_write
Writes the string out the connection. You can use it instead of the ns_return or ns_respond functions to build HTTP responses. AOLserver will not include the usual headers on the output data. The script does not end at the time ns_write* is invoked so you can continue processing data after the client has gotten the data and closed the socket.

SEE ALSO

ns_connsendfp, ns_respond, ns_returnadminnotice, ns_returnbadrequest, ns_returnerror, ns_returnfile, ns_returnforbidden, ns_returnfp, ns_returnnotfound, ns_returnnotice, ns_returnredirect, ns_returnunauthorized, ns_write