Return-Path: Delivered-To: apmail-jakarta-httpcomponents-dev-archive@www.apache.org Received: (qmail 87434 invoked from network); 23 Jul 2007 19:26:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jul 2007 19:26:58 -0000 Received: (qmail 89349 invoked by uid 500); 23 Jul 2007 19:26:55 -0000 Delivered-To: apmail-jakarta-httpcomponents-dev-archive@jakarta.apache.org Received: (qmail 89146 invoked by uid 500); 23 Jul 2007 19:26:54 -0000 Mailing-List: contact httpcomponents-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list httpcomponents-dev@jakarta.apache.org Received: (qmail 89086 invoked by uid 99); 23 Jul 2007 19:26:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jul 2007 12:26:54 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jul 2007 12:26:51 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 585B7714201 for ; Mon, 23 Jul 2007 12:26:31 -0700 (PDT) Message-ID: <32564064.1185218791359.JavaMail.jira@brutus> Date: Mon, 23 Jul 2007 12:26:31 -0700 (PDT) From: "Oleg Kalnichevski (JIRA)" To: httpcomponents-dev@jakarta.apache.org Subject: [jira] Commented: (HTTPCORE-104) Handler Registry Should Match Using Regular Expressions In-Reply-To: <28216171.1184953026593.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HTTPCORE-104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12514747 ] Oleg Kalnichevski commented on HTTPCORE-104: -------------------------------------------- Nels, The only reason we want to retain 1.3 compatibility for HttpCore is to keep it portable to the Java ME platform. If you are targeting JSE or JEE platforms I personally see no reason for not using Java 1.4 or newer. Oleg > Handler Registry Should Match Using Regular Expressions > ------------------------------------------------------- > > Key: HTTPCORE-104 > URL: https://issues.apache.org/jira/browse/HTTPCORE-104 > Project: HttpComponents Core > Issue Type: Improvement > Components: HttpCore > Affects Versions: 4.0-alpha4, 4.0-alpha5, 4.0-alpha6, 4.0-beta1, 4.0-rc1 > Reporter: Nels N. Nelson > Fix For: 4.0-alpha6 > > > Hello! > In HttpRequestHandlerRegistry, the method matchUriRequestPattern(final String pattern, final String requestUri) uses what is, in my opinion, a poor strategy for pattern matching. > This method is better and provides more flexibility to developers trying to add new Handlers: > > protected boolean matchUriRequestPattern(final String pattern, > final URI requestUri) > { > try { > String path = requestUri.getPath(); > Pattern p = Pattern.compile(pattern); > Matcher matcher = p.matcher(path); > return matcher.matches(); > } > catch (java.util.regex.PatternSyntaxException ex) { > return false; > } > } > > These changes would make this code far more accurate: > > protected void doService( > final HttpRequest request, > final HttpResponse response, > final HttpContext context) throws HttpException, IOException { > HttpRequestHandler handler = null; > if (this.handlerResolver != null) { > URI requestURI = request.getRequestLine().getUri(); > handler = this.handlerResolver.lookup(requestURI); > } > if (handler != null) { > handler.handle(request, response, context); > } else { > response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED); > } > } > > These changes would allow developers to add new custom handlers in this way: > > String pattern = ".*\\.extension"; > HttpRequestHandler handler = new HttpServletHandler(...); > HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); > reqistry.register(pattern, handler); > > Currently, my version of the HttpComponents core software uses URI to represent the requestURI parameter throughout the code. This has provided greater convenience, error handling (in the instantiation of the BasicRequestLine class, for instance), and flexibility of extension. I can enumerate the specifics on this, if necessary, but I believe that would be a discussion for a separate Jira Issue, which I will happily create, if I am convinced that its priority would be at least major, which currently, I am not. Such a change would cause several changes throughout multiple classes, stemming from changes to the RequestLine interface as follows: > > public interface RequestLine { > String getMethod(); > HttpVersion getHttpVersion(); > URI getUri(); > > } > > Thanks for your attention to this issue. > -Nels -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org