B.1. An HTTP interaction

A simple example of an HTTP interaction might go as follows:

1. A browser makes a TCP/IP connection over the Internet to a server's TCP/IP Port 80 and transmits an HTTP request message containing:

  • An HTTP request method is a command sent to the HTTP server, such as GET MainPage.vxml HTTP/1.0. (See Table B-3 for a list of all HTTP request methods.)

  • An optional HTTP request header contains information about the browser so the server can customize its response.

  • An optional HTTP entity body contains information collected by the browser to be posted up to the server. This information is typically consumed by a Web application.

2. The server reads this message, then transmits an HTTP response containing:

  • A status line indicates the HTTP version, a status code (see Table B-1 for a list of HTTP status codes), and a short status description.

  • An HTTP response header provides information about the HTTP server and about the document that the server is responding with, including the document type specified as a MIME type (see Table B-2 for a list of MIME types often used in VoiceXML) and the length of the document.

  • The HTTP entity body is the actual payload of the HTTP response. This typically contains the document requested by the browser.

Using VoiceXML's catch element, you can catch each different HTTP response status code and handle it differently. For example, if you want to have a particular behavior for a 500 - Internal Server Error status code, you could catch this event with the following catch element:

<catch event="error.badfetch.http.500">
...
</catch>

Table B-1. HTTP status codes
Status codeDescriptionDescription
100Continue The request was a part of a multipart request. The client may continue with the next part.
101Switching protocolsThe server is responding to a request from the client to switch protocols.
200OKThe request was successful. The requested resource will be sent with this response.
201CreatedThe creation of a new URI as requested by the client was successful.
202AcceptedThe request was accepted but may not be processed until later.
203Non-authorative informationThe information in the header is not from the original source but perhaps from a copy or local cache.
204No contentThe requested document is empty.
205Reset contentThe client should clear any forms that may be posted to the server on a subsequent request.
206Partial contentThe server is returning a portion of the requested resource as requested by the client.
300Multiple choicesThe URI used to specify this resource is ambiguous.
301Moved permanentlyThe requested URI has been moved permanently. The new URI is included in the Location HTTP response header item. The client should re-direct its request to that URI.
302Moved temporarilySimilar to 301, but with the implication that the move is only temporary.
303See otherSimilar to 301 and 302.
304Not modifiedThe server received an if-modified-since HTTP request header, but the resource requested has not been modified by the given date.
305Use proxyThe server advises that the client redirect its request to the proxy server specified in the Location HTTP response header item.
400Bad requestThere was a syntax error in the client's request.
401UnauthorizedThe client is not authorized to retrieve the given resource.
402ForbiddenThe server can not transmit the given resource.
404Not foundThe requested resource was not found on the server.
405Method not allowedThe method specified in the HTTP request is not allowed on this server.
406Not acceptableThe requested resource exists but is not in one of the acceptable formats specified by the client in the HTTP request header.
407Proxy authentication requiredThe proxy server needs to authorize the request before it can be processed.
408Request time-outThe client did not complete its request within some server-specific time-out period.
409ConflictThis request conflicts with another request.
410GoneThe URI has been permanently removed.
411Length requiredThe server requires a Content-Length HTTP request header.
412Precondition failedOne or more of the if-headers in the HTTP request failed.
413Request entity too largeThe request's entity body is too large for the server to process.
414Request URI too longThe request's URI is too long for the server to process.
415Unsupported media typeThe request's entity body is of an unsupported format.
500Internal Server errorThe server encountered an internal error (e.g. a bug in a Web application) and failed to generate a response.
501Not implementedThe server does not support the request.
502Bad gatewayThe server received an invalid response from another server while trying to process this request.
503Service unavailableThe service being requested is temporarily down. It will be available after the time specified in the retry-after HTTP response header item.
504Gateway time-outThe server could not generate a response within a set time-out.
505HTTP version not supportedThe server does not support the version of HTTP specified in the request.

MIME types are a standardized way of describing resource types such as images, audio clips, HTML documents, Microsoft Word documents, etc. Since a VoiceXML interpreter cannot interpret many of the formats popular in the browser-based WWW, the MIME types pertinent to VoiceXML are limited to text formats and audio formats. A brief summary of these MIME types is in Table B-2.

Table B-2. Pertinent MIME types
MIME typeDescription
audio/32kadpcmau, snd formatted audio files
audio/basicau, snd formatted audio files
audio/x-aiffaif, aiff, aifc formatted audio files
audio/x-wavwav formatted audio files
message/httpa message expanding an HTTP status code
text/htmlan HTML document represented as plain text
text/xmlan XML document represented as plain text
text/plaina text document with no markup

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.142.80