1 package org.sapia.ubik.net.mplex; 2 3 4 22 public class HttpStreamSelector implements StreamSelector { 23 24 private String _theMethod; 25 26 27 private String _theRequestPatern; 28 29 32 public HttpStreamSelector() { 33 } 34 35 46 public HttpStreamSelector(String aMethod, String aRequestPattern) { 47 _theMethod = aMethod; 48 _theRequestPatern = aRequestPattern; 49 } 50 51 57 public boolean selectStream(byte[] header) { 58 String aStringValue = new String (header); 59 60 int firstSpace = aStringValue.indexOf(" "); 61 62 if (firstSpace > 0) { 63 if (_theMethod != null) { 65 if (!aStringValue.substring(0, firstSpace).equals(_theMethod)) { 66 return false; 67 } 68 } 69 70 int secondSpace = aStringValue.indexOf(" ", firstSpace + 1); 71 72 if (secondSpace > firstSpace) { 73 if (_theRequestPatern != null) { 75 if (!aStringValue.substring(firstSpace + 1, secondSpace).startsWith(_theRequestPatern)) { 76 return false; 77 } 78 } 79 80 if (aStringValue.substring(secondSpace + 1, secondSpace + 6).equals("HTTP/")) { 82 return true; 83 } else { 84 return false; 85 } 86 } else { 87 return false; 88 } 89 } else { 90 return false; 91 } 92 } 93 } 94 | Popular Tags |