- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Understanding HTTP Redirection in Font
Understanding HTTP Redirection Code 3/9 Maker In None Using Barcode generation for Font Control to generate, create Code39 image in Font applications. www.OnBarcode.comData Matrix ECC200 Encoder In None Using Barcode creation for Font Control to generate, create Data Matrix ECC200 image in Font applications. www.OnBarcode.comHTTP redirection is a handshaking protocol. The client makes a request, and the server receives and processes the request. If the server indicates a redirection is in order, then an HTTP status code in the 300 range is returned. Upon receiving the 300-range status code, the client inspects the response and can take action by loading the redirected URL. Barcode Creation In None Using Barcode generation for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comDrawing Code39 In None Using Barcode creator for Font Control to generate, create Code 39 Full ASCII image in Font applications. www.OnBarcode.comCHAPTER 7 7-1. IMPLEMENTING AN AJAX SHOPPING CART
Draw UCC-128 In None Using Barcode generator for Font Control to generate, create UCC-128 image in Font applications. www.OnBarcode.comGenerate UPC-A Supplement 2 In None Using Barcode generation for Font Control to generate, create UPCA image in Font applications. www.OnBarcode.comThe following is an example HTTP conversation that performs an HTTP redirection. As usual, a client makes an HTTP request: GET /resource/ HTTP/1.1 Accept: */* Accept-Language: en Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412.6.2 (KHTML, like Gecko) Safari/412.2.2 Connection: keep-alive Host: 192.168.1.242:8100 The URL /resource is recognized by the HTTP server as a generic URL that will redirect to a specific URL when called. The HTTP server responds with an HTTP 302 to indicate a redirection, as illustrated by the following HTTP response: HTTP/1.1 302 Found Date: Tues, 05 Sep 2005 16:29:04 GMT Server: Apache/2.0.53 (Ubuntu) PHP/4.3.10-10ubuntu4 Location: /resource/joesmith Content-Length: 346 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html; charset=iso-8859-1 In the example, the specific URL sent to the client is defined as /resource/joesmith. When either a Web browser or an XMLHttpRequest object receives a redirect, the client will recognize the redirect and attempt to retrieve the contents of the redirected URL, as illustrated by the following final request: GET /resource/joesmith HTTP/1.1 Accept: */* Accept-Language: en Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412.6.2 (KHTML, like Gecko) Safari/412.2.2 Connection: keep-alive Host: 192.168.1.242:8100 An HTTP redirection, whether executed by the Web browser or XMLHttpRequest, can be executed only if the redirection follows the same origin policy. If a redirection to another domain is attempted with XMLHttpRequest, the results vary. For example, Microsoft Internet Explorer returns a status code of 0 and no further data. Mozilla-based browsers return the status code 302 and the redirected URL. Although using HTTP redirection can be effective, it can also be problematic from an Ajax perspective. When using the XMLHttpRequest object and calling a URL that generates a redirection, the redirected URL will be loaded automatically. This is bad because the script needs to know what the redirected URL is, but the XMLHttpRequest object doesn t give that URL. Therefore, in the context of this recipe, you cannot use a 300-range HTTP status code. Encoding Barcode In None Using Barcode drawer for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comCreating USD8 In None Using Barcode generator for Font Control to generate, create USD - 8 image in Font applications. www.OnBarcode.comCHAPTER 7 7-1. IMPLEMENTING AN AJAX SHOPPING CART
Recognize Code 39 In None Using Barcode decoder for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comPrinting Code39 In Java Using Barcode creation for Java Control to generate, create Code 39 Extended image in Java applications. www.OnBarcode.comCreating HTTP Resources
Making USS Code 39 In Visual Studio .NET Using Barcode drawer for .NET framework Control to generate, create Code 3 of 9 image in VS .NET applications. www.OnBarcode.comDecoding UPCA In Visual Basic .NET Using Barcode decoder for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comIt would seem that the original idea of retrieving the unique URL in the body of the action URL response is the only solution, but never fear. Another solution does exist, and it s compliant with the HTTP protocol. The HTTP status code 201 corresponds to a response where the server has created another URL that can be found in the Location HTTP header. This logic corresponds closely to what the role of the action URL is with respect to the unique URL. When the server responds with an HTTP status 201, the browser or XMLHttpRequest instance doesn t perform a redirect automatically. It s up to the code or browser to take action on the response. You can use the following JavaScript class to retrieve the unique URL from the action URL. Source: /client/scripts/jaxson/communications.js function UniqueURL( url) { this.asynchronous = null; this.baseURL = url; this.uniqueURL = null; this.haveIt = function() { } } UniqueURL.prototype.getIt = function() { var instance = this; this.asynchronous = FactoryHttp.getAsynchronous(); this.asynchronous.settings = { onComplete : function(xmlhttp) { if( xmlhttp.status == 201) { instance.uniqueURL = xmlhttp.getResponseHeader( "Location"); instance.haveIt(); } } } this.asynchronous.get(this.baseURL); } UniqueURL.prototype.postIt = function( inpData) { var instance = this; this.asynchronous = FactoryHttp.getAsynchronous(); this.asynchronous.settings = { onComplete : function(xmlhttp) { if( xmlhttp.status == 201) { instance.uniqueURL = xmlhttp.getResponseHeader( "Location"); instance.haveIt(); } } } this.asynchronous.post(this.baseURL, inpData); } Decode Barcode In Java Using Barcode Control SDK for BIRT Control to generate, create, read, scan barcode image in Eclipse BIRT applications. www.OnBarcode.comMaking Barcode In None Using Barcode printer for Software Control to generate, create Barcode image in Software applications. www.OnBarcode.comPDF417 Recognizer In .NET Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comGenerating EAN13 In VS .NET Using Barcode creation for Visual Studio .NET Control to generate, create EAN-13 Supplement 5 image in .NET framework applications. www.OnBarcode.comCode 39 Reader In Visual C# Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comBarcode Maker In Java Using Barcode encoder for Android Control to generate, create Barcode image in Android applications. www.OnBarcode.comUPC Symbol Drawer In None Using Barcode drawer for Online Control to generate, create UCC - 12 image in Online applications. www.OnBarcode.comMaking Code128 In Objective-C Using Barcode creator for iPad Control to generate, create Code 128 Code Set A image in iPad applications. www.OnBarcode.com |
|