@Override public boolean equals(Object o) { if (!(o instanceof HttpMethod)) { return false; } HttpMethod that = (HttpMethod) o; return name().equals(that.name()); }
@Override protected boolean isContentAlwaysEmpty(HttpMessage msg) { final int statusCode = ((HttpResponse) msg).getStatus().code(); if (statusCode == 100) { // 100-continue response should be excluded from paired comparison. return true; } // Get the getMethod of the HTTP request that corresponds to the // current response. HttpMethod method = queue.poll(); char firstChar = method.name().charAt(0); switch (firstChar) { case 'H': // According to 4.3, RFC2616: // All responses to the HEAD request getMethod MUST NOT include a // message-body, even though the presence of entity-header fields // might lead one to believe they do. if (HttpMethod.HEAD.equals(method)) { return true; // The following code was inserted to work around the servers // that behave incorrectly. It has been commented out // because it does not work with well behaving servers. // Please note, even if the 'Transfer-Encoding: chunked' // header exists in the HEAD response, the response should // have absolutely no content. // //// Interesting edge case: //// Some poorly implemented servers will send a zero-byte //// chunk if Transfer-Encoding of the response is 'chunked'. //// //// return !msg.isChunked(); } break; case 'C': // Successful CONNECT request results in a response with empty body. if (statusCode == 200) { if (HttpMethod.CONNECT.equals(method)) { // Proxy connection established - Not HTTP anymore. done = true; queue.clear(); return true; } } break; } return super.isContentAlwaysEmpty(msg); }
@Override public int compareTo(HttpMethod o) { return name().compareTo(o.name()); }