diff --git a/source/de/anomic/http/http.java b/source/de/anomic/http/http.java new file mode 100644 index 000000000..2faa068bc --- /dev/null +++ b/source/de/anomic/http/http.java @@ -0,0 +1,72 @@ +//http.java +//----------------------- +//(C) by Michael Peter Christen; mc@anomic.de +//first published on http://www.anomic.de +//Frankfurt, Germany, 2005 +//last change: 13.05.2005 by Martin Thelian +// +//This program is free software; you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation; either version 2 of the License, or +//(at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License +//along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//Using this software in any meaning (reading, learning, copying, compiling, +//running) means that you agree that the Author(s) is (are) not responsible +//for cost, loss of data or any harm that may be caused directly or indirectly +//by usage of this softare or this documentation. The usage of this software +//is on your own risk. The installation and usage (starting/running) of this +//software may allow other people or application to access your computer and +//any attached devices and is highly dependent on the configuration of the +//software which must be done by the user of the software; the author(s) is +//(are) also not responsible for proper configuration and usage of the +//software, even if provoked by documentation provided together with +//the software. +// +//Any changes to this file according to the GPL as documented in the file +//gpl.txt aside this file in the shipment you received can be done to the +//lines that follows this copyright notice here, but changes must not be +//done inside the copyright notive above. A re-distribution must contain +//the intact and unchanged copyright notice. +//Contributions and changes to the program code must be marked as such. + +package de.anomic.http; + +public final class http { + + /* ============================================================= + * Constants defining http methods + * ============================================================= */ + public static final String METHOD_GET = "GET"; + public static final String METHOD_HEAD = "HEAD"; + public static final String METHOD_POST = "POST"; + public static final String METHOD_CONNECT = "CONNECT"; + + /* ============================================================= + * Constants defining http header names + * ============================================================= */ + public static final String HEADER_ACCEPT = "Accept"; + public static final String HEADER_ACCEPT_CHARSET = "Accept-Charset"; + public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language"; + public static final String HEADER_KEEP_ALIVE = "Keep-Alive"; + public static final String HEADER_USER_AGENT = "User-Agent"; + public static final String HEADER_HOST = "Host"; + public static final String HEADER_CONNECTION = "Connection"; + public static final String HEADER_REFERER = "Referer"; + public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding"; + public static final String HEADER_CONTENT_LENGTH = "CONTENT-LENGTH"; + public static final String HEADER_CONTENT_TYPE = "CONTENT-TYPE"; + public static final String HEADER_AUTHORIZATION = "Authorization"; + public static final String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate"; + public static final String HEADER_PROXY_AUTHORIZATION = "Proxy-Authorization"; + public static final String HEADER_PROXY_AUTHENTICATE = "Proxy-Authenticate"; + +} diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java index f98a63e09..106674c23 100644 --- a/source/de/anomic/http/httpc.java +++ b/source/de/anomic/http/httpc.java @@ -194,7 +194,7 @@ public final class httpc { newHttpc = (httpc) httpc.theHttpcPool.borrowObject(); } catch (Exception e) { - throw new IOException("Unable to initialize a new httpc. " + e.getMessage()); + throw new IOException("Unable to fetch a new httpc from pool. " + e.getMessage()); } // initialize it @@ -586,36 +586,36 @@ public final class httpc { if (header == null) header = new httpHeader(); // set some standard values - if (!(header.containsKey("Accept"))) - header.put("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); - if (!(header.containsKey("Accept-Charset"))) - header.put("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); - if (!(header.containsKey("Accept-Language"))) - header.put("Accept-Language", "en-us,en;q=0.5"); - if (!(header.containsKey("Keep-Alive"))) - header.put("Keep-Alive", "300"); + if (!(header.containsKey(http.HEADER_ACCEPT))) + header.put(http.HEADER_ACCEPT, "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); + if (!(header.containsKey(http.HEADER_ACCEPT_CHARSET))) + header.put(http.HEADER_ACCEPT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); + if (!(header.containsKey(http.HEADER_ACCEPT_LANGUAGE))) + header.put(http.HEADER_ACCEPT_LANGUAGE, "en-us,en;q=0.5"); + if (!(header.containsKey(http.HEADER_KEEP_ALIVE))) + header.put(http.HEADER_KEEP_ALIVE, "300"); // set user agent. The user agent is only set if the value does not yet exists. // this gives callers the opportunity, to change the user agent themselves, and // it will not be changed. - if (!(header.containsKey("User-Agent"))) header.put("User-Agent", userAgent); + if (!(header.containsKey(http.HEADER_USER_AGENT))) header.put(http.HEADER_USER_AGENT, userAgent); // set the host attribute. This is in particular necessary, if we contact another proxy // the host is mandatory, if we use HTTP/1.1 - if (!(header.containsKey("Host"))) { + if (!(header.containsKey(http.HEADER_HOST))) { if (this.remoteProxyUse) - header.put("Host", savedRemoteHost); + header.put(http.HEADER_HOST, savedRemoteHost); else - header.put("Host", this.host); + header.put(http.HEADER_HOST, this.host); } - if (!(header.containsKey("Connection"))) { - header.put("Connection", "close"); + if (!(header.containsKey(http.HEADER_CONNECTION))) { + header.put(http.HEADER_CONNECTION, "close"); } // advertise a little bit... - if ((!(header.containsKey("Referer"))) || (((String) header.get("Referer")).trim().length() == 0)) { - header.put("Referer", + if ((!(header.containsKey(http.HEADER_REFERER))) || (((String) header.get(http.HEADER_REFERER)).trim().length() == 0)) { + header.put(http.HEADER_REFERER, (((System.currentTimeMillis() >> 10) & 1) == 0) ? "http://www.anomic.de" : "http://www.yacy.net/yacy"); @@ -623,30 +623,30 @@ public final class httpc { // stimulate zipping or not // we can unzip, and we will return it always as unzipped, unless not wanted - if (header.containsKey("Accept-Encoding")) { - String encoding = (String) header.get("Accept-Encoding"); + if (header.containsKey(http.HEADER_ACCEPT_ENCODING)) { + String encoding = (String) header.get(http.HEADER_ACCEPT_ENCODING); if (zipped) { if (encoding.indexOf("gzip") < 0) { // add the gzip encoding //System.out.println("!!! adding gzip encoding"); - header.put("Accept-Encoding", "gzip,deflate" + ((encoding.length() == 0) ? "" : (";" + encoding))); + header.put(http.HEADER_ACCEPT_ENCODING, "gzip,deflate" + ((encoding.length() == 0) ? "" : (";" + encoding))); } } else { int pos = encoding.indexOf("gzip"); if (pos >= 0) { // remove the gzip encoding //System.out.println("!!! removing gzip encoding"); - header.put("Accept-Encoding", encoding.substring(0, pos) + encoding.substring(pos + 4)); + header.put(http.HEADER_ACCEPT_ENCODING, encoding.substring(0, pos) + encoding.substring(pos + 4)); } } } else { - if (zipped) header.put("Accept-Encoding", "gzip,deflate"); + if (zipped) header.put(http.HEADER_ACCEPT_ENCODING, "gzip,deflate"); } //header = new httpHeader(); header.put("Host", this.host); // debug // send request - if ((this.remoteProxyUse) && (!(method.equals("CONNECT")))) + if ((this.remoteProxyUse) && (!(method.equals(http.METHOD_CONNECT)))) path = "http://" + this.savedRemoteHost + path; serverCore.send(clientOutput, method + " " + path + " HTTP/1.0"); // if set to HTTP/1.1, servers give time-outs? @@ -687,7 +687,7 @@ public final class httpc { //serverLog.logDebug("HTTPC", handle + " requested GET '" + path + "', time = " + (System.currentTimeMillis() - handle)); try { boolean zipped = shallTransportZipped(path); - send("GET", path, requestHeader, zipped); + send(http.METHOD_GET, path, requestHeader, zipped); response r = new response(zipped); //serverLog.logDebug("HTTPC", handle + " returned GET '" + path + "', time = " + (System.currentTimeMillis() - handle)); return r; @@ -698,7 +698,7 @@ public final class httpc { public response HEAD(String path, httpHeader requestHeader) throws IOException { try { - send("HEAD", path, requestHeader, false); + send(http.METHOD_HEAD, path, requestHeader, false); return new response(false); // in this case the caller should not read the response body, // since there is none... @@ -709,9 +709,9 @@ public final class httpc { public response POST(String path, httpHeader requestHeader, InputStream ins) throws IOException { try { - send("POST", path, requestHeader, false); + send(http.METHOD_POST, path, requestHeader, false); // if there is a body to the call, we would have a CONTENT-LENGTH tag in the requestHeader - String cl = (String) requestHeader.get("CONTENT-LENGTH"); + String cl = (String) requestHeader.get(http.HEADER_CONTENT_LENGTH); int len, c; byte[] buffer = new byte[512]; if (cl != null) { @@ -727,7 +727,7 @@ public final class httpc { clientOutput.write(buffer, 0, c); len += c; } - requestHeader.put("CONTENT-LENGTH", "" + len); + requestHeader.put(http.HEADER_CONTENT_LENGTH, "" + len); } clientOutput.flush(); return new response(false); @@ -738,7 +738,7 @@ public final class httpc { public response CONNECT(String host, int port, httpHeader requestHeader) throws IOException { try { - send("CONNECT", host + ":" + port, requestHeader, false); + send(http.METHOD_CONNECT, host + ":" + port, requestHeader, false); return new response(false); } catch (SocketException e) { throw new IOException(e.getMessage()); @@ -750,18 +750,18 @@ public final class httpc { // make shure, the header has a boundary information like // CONTENT-TYPE=multipart/form-data; boundary=----------0xKhTmLbOuNdArY if (requestHeader == null) requestHeader = new httpHeader(); - String boundary = (String) requestHeader.get("CONTENT-TYPE"); + String boundary = (String) requestHeader.get(http.HEADER_CONTENT_TYPE); if (boundary == null) { // create a boundary boundary = "multipart/form-data; boundary=----------" + java.lang.System.currentTimeMillis(); - requestHeader.put("CONTENT-TYPE", boundary); + requestHeader.put(http.HEADER_CONTENT_TYPE, boundary); } // extract the boundary string int pos = boundary.toUpperCase().indexOf("BOUNDARY="); if (pos < 0) { // again, create a boundary boundary = "multipart/form-data; boundary=----------" + java.lang.System.currentTimeMillis(); - requestHeader.put("CONTENT-TYPE", boundary); + requestHeader.put(http.HEADER_CONTENT_TYPE, boundary); pos = boundary.indexOf("boundary="); } boundary = "--" + boundary.substring(pos + "boundary=".length()); @@ -806,10 +806,10 @@ public final class httpc { byte[] body = buf.toByteArray(); //System.out.println("DEBUG: PUT BODY=" + new String(body)); // size of that body - requestHeader.put("CONTENT-LENGTH", "" + body.length); + requestHeader.put(http.HEADER_CONTENT_LENGTH, "" + body.length); // send the header //System.out.println("header=" + requestHeader); - send("POST", path, requestHeader, false); + send(http.METHOD_POST, path, requestHeader, false); // send the body //System.out.println("body=" + buf.toString()); serverCore.send(clientOutput, body); @@ -877,7 +877,7 @@ do upload httpHeader requestHeader) throws IOException { if (requestHeader == null) requestHeader = new httpHeader(); if ((user != null) && (password != null) && (user.length() != 0)) { - requestHeader.put("Authorization", serverCodings.standardCoder.encodeBase64String(user + ":" + password)); + requestHeader.put(http.HEADER_AUTHORIZATION, serverCodings.standardCoder.encodeBase64String(user + ":" + password)); } httpc con = null; @@ -935,7 +935,7 @@ do upload if (requestHeader == null) requestHeader = new httpHeader(); if ((user != null) && (password != null) && (user.length() != 0)) { - requestHeader.put("Authorization", serverCodings.standardCoder.encodeBase64String(user + ":" + password)); + requestHeader.put(http.HEADER_AUTHORIZATION, serverCodings.standardCoder.encodeBase64String(user + ":" + password)); } httpc con = null; @@ -1003,7 +1003,7 @@ do upload // generate request header httpHeader requestHeader = new httpHeader(); if ((user != null) && (password != null) && (user.length() != 0)) { - requestHeader.put("Authorization", serverCodings.standardCoder.encodeBase64String(user + ":" + password)); + requestHeader.put(http.HEADER_AUTHORIZATION, serverCodings.standardCoder.encodeBase64String(user + ":" + password)); } // parse query diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java index 5409b1d71..f4d360834 100644 --- a/source/de/anomic/http/httpd.java +++ b/source/de/anomic/http/httpd.java @@ -202,10 +202,10 @@ public final class httpd implements serverHandler { } private void transparentProxyHandling(httpHeader header) { - if (!(httpdProxyHandler.isTransparentProxy && header.containsKey("HOST"))) return; + if (!(httpdProxyHandler.isTransparentProxy && header.containsKey(http.HEADER_HOST))) return; try { - String dstHost, dstHostSocket = (String) header.get("HOST"); + String dstHost, dstHostSocket = (String) header.get(http.HEADER_HOST); int idx = dstHostSocket.indexOf(":"); dstHost = (idx != -1) ? dstHostSocket.substring(0,idx).trim() : dstHostSocket.trim(); @@ -213,11 +213,11 @@ public final class httpd implements serverHandler { if (dstPort.intValue() == 80) { if (dstHost.endsWith(".yacy")) { - this.prop.setProperty("HOST",dstHostSocket); + this.prop.setProperty(http.HEADER_HOST,dstHostSocket); } else { InetAddress dstHostAddress = InetAddress.getByName(dstHost); if (!(dstHostAddress.isAnyLocalAddress() || dstHostAddress.isLoopbackAddress())) { - this.prop.setProperty("HOST",dstHostSocket); + this.prop.setProperty(http.HEADER_HOST,dstHostSocket); } } } @@ -226,7 +226,7 @@ public final class httpd implements serverHandler { public Boolean GET(String arg) throws IOException { parseQuery(prop, arg); - prop.setProperty("METHOD", "GET"); + prop.setProperty("METHOD", http.METHOD_GET); prop.setProperty("CLIENTIP", clientIP); // we now know the HTTP version. depending on that, we read the header @@ -244,14 +244,14 @@ public final class httpd implements serverHandler { // persistent by default, but closed with the "Connection: close" // property. boolean persistent = (!((httpVersion.equals("HTTP/0.9")) || (httpVersion.equals("HTTP/1.0")))); - String connection = prop.getProperty("Connection", "close").toLowerCase(); + String connection = prop.getProperty(http.HEADER_CONNECTION, "close").toLowerCase(); if (connection.equals("close")) persistent = false; if (connection.equals("keep-alive")) persistent = true; //System.out.println("HEADER: " + header.toString()); // return multi-line message - if (prop.getProperty("HOST").equals(virtualHost)) { + if (prop.getProperty(http.HEADER_HOST).equals(virtualHost)) { // pass to server if (allowServer) { if (serverAccountBase64MD5 == null) serverAccountBase64MD5 = switchboard.getConfig("serverAccountBase64MD5", ""); @@ -260,11 +260,11 @@ public final class httpd implements serverHandler { if (fileHandler == null) fileHandler = new httpdFileHandler(this.switchboard); fileHandler.doGet(prop, header, this.session.out); } else { - String auth = (String) header.get("Authorization"); + String auth = (String) header.get(http.HEADER_AUTHORIZATION); if (auth == null) { // authorization requested, but no authorizeation given in header. Ask for authenticate: session.out.write((httpVersion + " 401 log-in required" + serverCore.crlfString + - "WWW-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } else if (serverAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(auth.trim().substring(6)))) { @@ -275,7 +275,7 @@ public final class httpd implements serverHandler { // wrong password given: ask for authenticate again serverLog.logInfo("HTTPD", "Wrong log-in for account 'server' in HTTPD.GET " + prop.getProperty("PATH") + " from IP " + clientIP); session.out.write((httpVersion + " 401 log-in required" + serverCore.crlfString + - "WWW-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } @@ -290,13 +290,13 @@ public final class httpd implements serverHandler { if (allowProxy) { if (proxyAccountBase64MD5 == null) proxyAccountBase64MD5 = switchboard.getConfig("proxyAccountBase64MD5", ""); if ((proxyAccountBase64MD5.length() == 0) || - (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get("Proxy-Authorization", "xxxxxx")).trim().substring(6))))) { + (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get(http.HEADER_PROXY_AUTHORIZATION, "xxxxxx")).trim().substring(6))))) { // we are authorized or no authenticate requested if (proxyHandler != null) proxyHandler.doGet(prop, header, this.session.out); } else { // ask for authenticate session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.crlfString + - "Proxy-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } @@ -311,7 +311,7 @@ public final class httpd implements serverHandler { public Boolean HEAD(String arg) throws IOException { parseQuery(prop,arg); - prop.setProperty("METHOD", "HEAD"); + prop.setProperty("METHOD", http.METHOD_HEAD); prop.setProperty("CLIENTIP", clientIP); // we now know the HTTP version. depending on that, we read the header @@ -325,7 +325,7 @@ public final class httpd implements serverHandler { } // return multi-line message - if (prop.getProperty("HOST").equals(virtualHost)) { + if (prop.getProperty(http.HEADER_HOST).equals(virtualHost)) { // pass to server if (allowServer) { if (serverAccountBase64MD5 == null) serverAccountBase64MD5 = switchboard.getConfig("serverAccountBase64MD5", ""); @@ -334,11 +334,11 @@ public final class httpd implements serverHandler { if (fileHandler == null) fileHandler = new httpdFileHandler(this.switchboard); fileHandler.doHead(prop, header, this.session.out); } else { - String auth = (String) header.get("Authorization"); + String auth = (String) header.get(http.HEADER_AUTHORIZATION); if (auth == null) { // authorization requested, but no authorizeation given in header. Ask for authenticate: session.out.write((httpVersion + " 401 log-in required" + serverCore.crlfString + - "WWW-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } else if (serverAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(auth.trim().substring(6)))) { @@ -349,7 +349,7 @@ public final class httpd implements serverHandler { // wrong password given: ask for authenticate again serverLog.logInfo("HTTPD", "Wrong log-in for account 'server' in HTTPD.HEAD " + prop.getProperty("PATH") + " from IP " + clientIP); session.out.write((httpVersion + " 401 log-in required" + serverCore.crlfString + - "WWW-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } @@ -365,13 +365,13 @@ public final class httpd implements serverHandler { if (allowProxy) { if (proxyAccountBase64MD5 == null) proxyAccountBase64MD5 = switchboard.getConfig("proxyAccountBase64MD5", ""); if ((proxyAccountBase64MD5.length() == 0) || - (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get("Proxy-Authorization", "xxxxxx")).trim().substring(6))))) { + (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get(http.HEADER_PROXY_AUTHORIZATION, "xxxxxx")).trim().substring(6))))) { // we are authorized or no authenticate requested if (proxyHandler != null) proxyHandler.doHead(prop, header, this.session.out); } else { // ask for authenticate session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.crlfString + - "Proxy-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } @@ -387,7 +387,7 @@ public final class httpd implements serverHandler { public Boolean POST(String arg) throws IOException { parseQuery(prop, arg); - prop.setProperty("METHOD", "POST"); + prop.setProperty("METHOD", http.METHOD_POST); prop.setProperty("CLIENTIP", clientIP); // we now know the HTTP version. depending on that, we read the header @@ -406,7 +406,7 @@ public final class httpd implements serverHandler { if (connection.equals("keep-alive")) persistent = true; // return multi-line message - if (prop.getProperty("HOST").equals(virtualHost)) { + if (prop.getProperty(http.HEADER_HOST).equals(virtualHost)) { // pass to server if (allowServer) { if (serverAccountBase64MD5 == null) serverAccountBase64MD5 = switchboard.getConfig("serverAccountBase64MD5", ""); @@ -415,11 +415,11 @@ public final class httpd implements serverHandler { if (fileHandler == null) fileHandler = new httpdFileHandler(this.switchboard); fileHandler.doPost(prop, header, this.session.out, this.session.in); } else { - String auth = (String) header.get("Authorization"); + String auth = (String) header.get(http.HEADER_AUTHORIZATION); if (auth == null) { // ask for authenticate session.out.write((httpVersion + " 401 log-in required" + serverCore.crlfString + - "WWW-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } else if (serverAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(auth.trim().substring(6)))) { @@ -430,7 +430,7 @@ public final class httpd implements serverHandler { // wrong password given: ask for authenticate again serverLog.logInfo("HTTPD", "Wrong log-in for account 'server' in HTTPD.POST " + prop.getProperty("PATH") + " from IP " + clientIP); session.out.write((httpVersion + " 401 log-in required" + serverCore.crlfString + - "WWW-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } @@ -445,13 +445,13 @@ public final class httpd implements serverHandler { if (allowProxy) { if (proxyAccountBase64MD5 == null) proxyAccountBase64MD5 = switchboard.getConfig("proxyAccountBase64MD5", ""); if ((proxyAccountBase64MD5.length() == 0) || - (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get("Proxy-Authorization", "xxxxxx")).trim().substring(6))))) { + (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get(http.HEADER_PROXY_AUTHORIZATION, "xxxxxx")).trim().substring(6))))) { // we are authorized or no authenticate requested if (proxyHandler != null) proxyHandler.doPost(prop, header, this.session.out, this.session.in); } else { // ask for authenticate session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.crlfString + - "Proxy-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); return serverCore.TERMINATE_CONNECTION; } @@ -515,13 +515,13 @@ public final class httpd implements serverHandler { if (allowProxy) { if (proxyAccountBase64MD5 == null) proxyAccountBase64MD5 = switchboard.getConfig("proxyAccountBase64MD5", ""); if ((proxyAccountBase64MD5.length() == 0) || - (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get("Proxy-Authorization", "xxxxxx")).trim().substring(6))))) { + (proxyAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(((String) header.get(http.HEADER_PROXY_AUTHORIZATION, "xxxxxx")).trim().substring(6))))) { // we are authorized or no authenticate requested if (proxyHandler != null) proxyHandler.doConnect(prop, header, (InputStream) this.session.in, this.session.out); } else { // ask for authenticate session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.crlfString + - "Proxy-Authenticate: Basic realm=\"log-in\"" + serverCore.crlfString + + http.HEADER_PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.crlfString + serverCore.crlfString).getBytes()); } } else { @@ -708,7 +708,7 @@ public final class httpd implements serverHandler { // we parse a multipart message and put results into the properties // find/identify boundary marker //System.out.println("DEBUG parseMultipart = <<" + new String(buffer) + ">>"); - String s = (String) header.get("CONTENT-TYPE"); + String s = (String) header.get(http.HEADER_CONTENT_TYPE); if (s == null) return null; int q; int p = s.toLowerCase().indexOf("boundary=");