Code example for HttpRequest

Methods: getLastHeader, getRequestLine

0
		{ 
			private void interpretRangeThenSeek(HttpRequest req, 
			  RandomAccessStream stream) 
			  throws IOException 
			{ 
				Header hdr = req.getLastHeader("Range"); 
 
				if (hdr == null) 
					return; 
 
				String rangeStr = hdr.getValue(); 
				Pattern pattern = Pattern.compile("bytes=(\\d+)-(\\d+)"); 
				Matcher matcher = pattern.matcher(rangeStr); 
 
				if (matcher.matches() == false) 
				{ 
					Log.w(TAG, "Failed to parse range header: " + rangeStr); 
					return; 
				} 
 
				long low; 
				long high; 
 
				try { 
					low = Long.parseLong(matcher.group(1)); 
					high = Long.parseLong(matcher.group(2)); 
				} catch (NumberFormatException e) { 
					Log.w(TAG, "Failed to parse range header: " + rangeStr); 
					return; 
				} 
 
				/* We assume that high is actually just the end of the 
				 * stream as it was originally defined, so we aren't going 
				 * to honor it explicitly. */ 
				assert stream.size() == high; 
 
				Log.i(TAG, "Serving range " + low + "-" + high); 
				stream.seek(low); 
			} 
 
			public void handle(HttpRequest request, HttpResponse response, 
			  HttpContext context) 
			  throws HttpException, IOException 
			{ 
				RequestLine reqLine = request.getRequestLine(); 
				Log.v(TAG, "reqLine=" + reqLine); 
 
				String method = reqLine.getMethod().toUpperCase(Locale.ENGLISH); 
				if (method.equals("GET") == false) 
				{