private void copyHeadersToWebBrowser(final HttpURLConnection con, final OutputStream outputToWebBrowser) throws IOException
	{	  
		int i=0;
		while (true)
		{
			String value = con.getHeaderField(i);
			if (value == null)
			{
				break; // End of headers
			}

			String name = con.getHeaderFieldKey(i);

			i++;

			if ("Transfer-Encoding".equalsIgnoreCase(name))
			{
				continue; // We drop this heading as per RFC2616			
			}


			if (name != null)
			{
				// Some headers, like the status line, have no name
				outputToWebBrowser.write(name.getBytes());
				outputToWebBrowser.write(": ".getBytes());
				
				// Change the redirection to the localhost
				if (name.equals("Location"))
				{
					URL location;
					try 
					{
						location = new URL(value);
						if (location.getHost().equals(conf.getDestination().getHost())) 
						{
							location = new URL("http", "127.0.0.1", conf.getLocalPort(), 
								location.getFile());
							value = location.toString();
						}
					}
					catch (MalformedURLException ex) 
					{
						// Ignore - don't bother changing the Location header
					}
				}
			}

			outputToWebBrowser.write(value.getBytes());
			
			outputToWebBrowser.write('\r');
			outputToWebBrowser.write('\n');

			ui.debug("< "+name+": "+value);
			
		}
        
        // Mark the end of headers/start of body with a new line.
		outputToWebBrowser.write('\r');
		outputToWebBrowser.write('\n');
		
	}