idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
40,200 | public void add ( final URI uri , final HttpCookie cookie ) { if ( cookie . getMaxAge ( ) == 0 ) { return ; } if ( cookie . getDomain ( ) != null ) { add ( new DomainKey ( cookie ) , cookie ) ; } if ( uri != null ) { add ( new UriKey ( uri , cookie ) , cookie ) ; } } | public cookie store api |
40,201 | private boolean netscapeDomainMatches ( final String domain , final String host ) { if ( domain == null || host == null ) { return false ; } boolean isLocalDomain = ".local" . equalsIgnoreCase ( domain ) ; int embeddedDotInDomain = domain . indexOf ( '.' ) ; if ( embeddedDotInDomain == 0 ) { embeddedDotInDomain = domai... | shamelessly copied from jdk8 source code for InMemoryCookieStore |
40,202 | public static Object parse ( final ChainedHttpConfig config , final FromServer fromServer ) { try { final Csv . Context ctx = ( Csv . Context ) config . actualContext ( fromServer . getContentType ( ) , Csv . Context . ID ) ; return ctx . makeReader ( fromServer . getReader ( ) ) . readAll ( ) ; } catch ( IOException e... | Used to parse the server response content using the OpenCsv parser . |
40,203 | public static void encode ( final ChainedHttpConfig config , final ToServer ts ) { if ( handleRawUpload ( config , ts ) ) { return ; } final ChainedHttpConfig . ChainedRequest request = config . getChainedRequest ( ) ; final Csv . Context ctx = ( Csv . Context ) config . actualContext ( request . actualContentType ( ) ... | Used to encode the request content using the OpenCsv writer . |
40,204 | private void readAll ( ) { final List < CompletableFuture < Void > > futures = new ArrayList < > ( ) ; for ( File file : directory . listFiles ( ) ) { final Runnable loadFile = ( ) -> { if ( file . getName ( ) . endsWith ( SUFFIX ) ) { try ( FileReader reader = new FileReader ( file ) ) { Properties props = new Propert... | each cookie store controls its own directory we do not need to synchronize |
40,205 | @ SuppressWarnings ( "WeakerAccess" ) public static Object parse ( final ChainedHttpConfig config , final FromServer fromServer ) { try { final ObjectMapper mapper = ( ObjectMapper ) config . actualContext ( fromServer . getContentType ( ) , OBJECT_MAPPER_ID ) ; return mapper . readValue ( fromServer . getReader ( ) , ... | Used to parse the server response content using the Jackson JSON parser . |
40,206 | @ SuppressWarnings ( "WeakerAccess" ) public static void encode ( final ChainedHttpConfig config , final ToServer ts ) { try { if ( handleRawUpload ( config , ts ) ) { return ; } final ChainedHttpConfig . ChainedRequest request = config . getChainedRequest ( ) ; final ObjectMapper mapper = ( ObjectMapper ) config . act... | Used to encode the request content using the Jackson JSON encoder . |
40,207 | public static void mapper ( final HttpConfig config , final ObjectMapper mapper ) { mapper ( config , mapper , ContentTypes . JSON ) ; } | Used to configure the provided Jackson ObjectMapper in the configuration context for the default JSON content type . |
40,208 | public static void mapper ( final HttpConfig config , final ObjectMapper mapper , final Iterable < String > contentTypes ) { config . context ( contentTypes , OBJECT_MAPPER_ID , mapper ) ; } | Used to configure the provided Jackson ObjectMapper in the configuration context for the specified content type . |
40,209 | public static void toFile ( final HttpConfig config , final File file ) { toFile ( config , ContentTypes . ANY . getAt ( 0 ) , file ) ; } | Downloads the content to a specified file . |
40,210 | public static void toFile ( final HttpConfig config , final String contentType , final File file ) { config . context ( contentType , ID , file ) ; config . getResponse ( ) . parser ( contentType , Download :: fileParser ) ; } | Downloads the content to a specified file with the specified content type . |
40,211 | public static void toStream ( final HttpConfig config , final OutputStream ostream ) { toStream ( config , ContentTypes . ANY . getAt ( 0 ) , ostream ) ; } | Downloads the content into an OutputStream . |
40,212 | public static void toStream ( final HttpConfig config , final String contentType , final OutputStream ostream ) { config . context ( contentType , ID , ostream ) ; config . getResponse ( ) . parser ( contentType , Download :: streamParser ) ; } | Downloads the content into an OutputStream with the specified content type . |
40,213 | public Page title ( String title ) { properties . put ( Title , title ) ; String heading = ( String ) properties . get ( Heading ) ; if ( heading == null || heading . equals ( NoTitle ) ) properties . put ( Heading , title ) ; return this ; } | Set page title . |
40,214 | public final Page setBackGroundColor ( String color ) { properties . put ( BgColour , color ) ; attribute ( "bgcolor" , color ) ; return this ; } | Set page background color . |
40,215 | public final Page setBase ( String target , String href ) { base = "<base " + ( ( target != null ) ? ( "TARGET=\"" + target + "\"" ) : "" ) + ( ( href != null ) ? ( "HREF=\"" + href + "\"" ) : "" ) + ">" ; return this ; } | Set the URL Base for the Page . |
40,216 | public void writeBodyTag ( Writer out ) throws IOException { if ( ! writtenBodyTag ) { writtenBodyTag = true ; out . write ( "<body " + attributes ( ) + ">\n" ) ; } } | Write HTML page body tag . Write tags <BODY page attributes> . |
40,217 | public void write ( Writer out , String section , boolean endHtml ) throws IOException { writeHtmlHead ( out ) ; writeBodyTag ( out ) ; Composite s = getSection ( section ) ; if ( s == null ) { if ( section . equals ( Content ) ) writeElements ( out ) ; } else s . write ( out ) ; if ( endHtml ) writeHtmlEnd ( out ) ; o... | Write page section . The page is written containing only the named section . If a head and bodyTag have not been written then they are written before the section . If endHtml is true the end HTML tag is also written . If the named section is Content and it cannot be found then the normal page contents are written . |
40,218 | public void addSection ( String section , Composite composite ) { sections . put ( section , composite ) ; add ( composite ) ; } | Set a composite as a named section and add it to the . contents of the page |
40,219 | public void addTo ( String section , Object element ) { Composite s = ( Composite ) sections . get ( section ) ; if ( s == null ) add ( element ) ; else s . add ( element ) ; } | Add content to a named sections . If the named section cannot . be found the content is added to the page . |
40,220 | public void close ( ) throws IOException { try { _completing = true ; if ( _connection instanceof Socket && ! ( _connection instanceof SSLSocket ) ) ( ( Socket ) _connection ) . shutdownOutput ( ) ; _outputStream . close ( ) ; _inputStream . close ( ) ; } finally { if ( _handlingThread != null && Thread . currentThread... | Close the connection . This method calls close on the input and output streams and interrupts any thread in the handle method . may be specialized to close sockets etc . |
40,221 | public String getServerName ( ) { String host = _listener . getHost ( ) ; if ( InetAddrPort . __0_0_0_0 . equals ( host ) && _connection instanceof Socket ) host = ( ( Socket ) _connection ) . getLocalAddress ( ) . getHostName ( ) ; return host ; } | Get the listeners HttpServer . But if the name is 0 . 0 . 0 . 0 then the real interface address is used . |
40,222 | public String getServerAddr ( ) { if ( _connection instanceof Socket ) return ( ( Socket ) _connection ) . getLocalAddress ( ) . getHostAddress ( ) ; return _listener . getHost ( ) ; } | Get the listeners HttpServer . |
40,223 | protected void firstWrite ( ) throws IOException { if ( _response . isCommitted ( ) ) return ; if ( HttpRequest . __HEAD . equals ( _request . getMethod ( ) ) ) _outputStream . nullOutput ( ) ; int length = _response . getIntField ( HttpFields . __ContentLength ) ; if ( length >= 0 ) _outputStream . setContentLength ( ... | Setup the reponse output stream . Use the current state of the request and response to set tranfer parameters such as chunking and content length . |
40,224 | protected HttpContext service ( HttpRequest request , HttpResponse response ) throws HttpException , IOException { if ( _httpServer == null ) throw new HttpException ( HttpResponse . __503_Service_Unavailable ) ; return _httpServer . service ( request , response ) ; } | Service a Request . This implementation passes the request and response to the service method of the HttpServer for this connections listener . If no HttpServer has been associated the 503 is returned . This method may be specialized to implement other ways of servicing a request . |
40,225 | protected void recycle ( ) { _listener . persistConnection ( this ) ; if ( _request != null ) _request . recycle ( this ) ; if ( _response != null ) _response . recycle ( this ) ; } | Recycle the connection . called by handle when handleNext returns true . |
40,226 | protected void destroy ( ) { try { close ( ) ; } catch ( IOException e ) { LogSupport . ignore ( log , e ) ; } catch ( Exception e ) { log . warn ( LogSupport . EXCEPTION , e ) ; } if ( _request != null ) _request . destroy ( ) ; if ( _response != null ) _response . destroy ( ) ; if ( _inputStream != null ) _inputStrea... | Destroy the connection . called by handle when handleNext returns false . |
40,227 | protected Resource getResource ( String pathInContext ) throws IOException { Resource r = ( _resourceBase == null ) ? _httpContext . getResource ( pathInContext ) : _resourceBase . addPath ( pathInContext ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "RESOURCE=" + r ) ; return r ; } | get Resource to serve . Map a path to a resource . The default implementation calls HttpContext . getResource but derived servlets may provide their own mapping . |
40,228 | public static int type ( String type ) { if ( "request" . equalsIgnoreCase ( type ) ) return __REQUEST ; if ( "forward" . equalsIgnoreCase ( type ) ) return __FORWARD ; if ( "include" . equalsIgnoreCase ( type ) ) return __INCLUDE ; if ( "error" . equalsIgnoreCase ( type ) ) return __ERROR ; throw new IllegalArgumentEx... | Dispatch type from name |
40,229 | public String [ ] getProxyHostsWhiteList ( ) { if ( _proxyHostsWhiteList == null || _proxyHostsWhiteList . size ( ) == 0 ) return new String [ 0 ] ; String [ ] hosts = new String [ _proxyHostsWhiteList . size ( ) ] ; hosts = ( String [ ] ) _proxyHostsWhiteList . toArray ( hosts ) ; return hosts ; } | Get proxy host white list . |
40,230 | public void setProxyHostsWhiteList ( String [ ] hosts ) { if ( hosts == null || hosts . length == 0 ) _proxyHostsWhiteList = null ; else { _proxyHostsWhiteList = new HashSet ( ) ; for ( int i = 0 ; i < hosts . length ; i ++ ) if ( hosts [ i ] != null && hosts [ i ] . trim ( ) . length ( ) > 0 ) _proxyHostsWhiteList . a... | Set proxy host white list . |
40,231 | public String [ ] getProxyHostsBlackList ( ) { if ( _proxyHostsBlackList == null || _proxyHostsBlackList . size ( ) == 0 ) return new String [ 0 ] ; String [ ] hosts = new String [ _proxyHostsBlackList . size ( ) ] ; hosts = ( String [ ] ) _proxyHostsBlackList . toArray ( hosts ) ; return hosts ; } | Get proxy host black list . |
40,232 | public void setProxyHostsBlackList ( String [ ] hosts ) { if ( hosts == null || hosts . length == 0 ) _proxyHostsBlackList = null ; else { _proxyHostsBlackList = new HashSet ( ) ; for ( int i = 0 ; i < hosts . length ; i ++ ) if ( hosts [ i ] != null && hosts [ i ] . trim ( ) . length ( ) > 0 ) _proxyHostsBlackList . a... | Set proxy host black list . |
40,233 | protected void customizeConnection ( String pathInContext , String pathParams , HttpRequest request , Socket socket ) throws IOException { } | Customize proxy Socket connection for CONNECT . Method to allow derived handlers to customize the tunnel sockets . |
40,234 | protected void customizeConnection ( String pathInContext , String pathParams , HttpRequest request , URLConnection connection ) throws IOException { } | Customize proxy URL connection . Method to allow derived handlers to customize the connection . |
40,235 | protected URL isProxied ( URI uri ) throws MalformedURLException { if ( isForbidden ( uri ) ) return null ; return new URL ( uri . toString ( ) ) ; } | Is URL Proxied . Method to allow derived handlers to select which URIs are proxied and to where . |
40,236 | protected boolean isForbidden ( URI uri ) { String scheme = uri . getScheme ( ) ; String host = uri . getHost ( ) ; int port = uri . getPort ( ) ; return isForbidden ( scheme , host , port , true ) ; } | Is URL Forbidden . |
40,237 | protected boolean isForbidden ( String scheme , String host , int port , boolean openNonPrivPorts ) { Integer p = new Integer ( port ) ; if ( port > 0 && ! _allowedConnectPorts . contains ( p ) ) { if ( ! openNonPrivPorts || port <= 1024 ) return true ; } if ( scheme == null || ! _ProxySchemes . containsKey ( scheme ) ... | Is scheme host & port Forbidden . |
40,238 | public FilterHolder addFilterPathMapping ( String pathSpec , String filterName , int dispatches ) { FilterHolder holder = ( FilterHolder ) _filterMap . get ( filterName ) ; if ( holder == null ) throw new IllegalArgumentException ( "unknown filter: " + filterName ) ; FilterMapping mapping = new FilterMapping ( pathSpec... | Add a mapping from a pathSpec to a Filter . |
40,239 | public FilterHolder addFilterServletMapping ( String servletName , String filterName , int dispatches ) { FilterHolder holder = ( FilterHolder ) _filterMap . get ( filterName ) ; if ( holder == null ) throw new IllegalArgumentException ( "Unknown filter :" + filterName ) ; _servletFilterMap . add ( servletName , new Fi... | Add a servlet filter mapping |
40,240 | public static ServletHttpResponse unwrap ( ServletResponse response ) { while ( ! ( response instanceof ServletHttpResponse ) ) { if ( response instanceof ServletResponseWrapper ) { ServletResponseWrapper wrapper = ( ServletResponseWrapper ) response ; response = wrapper . getResponse ( ) ; } else throw new IllegalArgu... | Unwrap a ServletResponse . |
40,241 | public static int [ ] toArray ( String s , int family ) { byte [ ] byteArray = toByteArray ( s , family ) ; if ( byteArray == null ) return null ; int [ ] intArray = new int [ byteArray . length ] ; for ( int i = 0 ; i < byteArray . length ; i ++ ) intArray [ i ] = byteArray [ i ] & 0xFF ; return intArray ; } | Convert a string containing an IP address to an array of 4 or 16 integers . |
40,242 | public static byte [ ] toByteArray ( String s , int family ) { if ( family == IPv4 ) return parseV4 ( s ) ; else if ( family == IPv6 ) return parseV6 ( s ) ; else throw new IllegalArgumentException ( "unknown address family" ) ; } | Convert a string containing an IP address to an array of 4 or 16 bytes . |
40,243 | public static boolean isDottedQuad ( String s ) { byte [ ] address = Address . toByteArray ( s , IPv4 ) ; return ( address != null ) ; } | Determines if a string contains a valid IP address . |
40,244 | public static InetAddress getByName ( String name ) throws UnknownHostException { try { return getByAddress ( name ) ; } catch ( UnknownHostException e ) { Record [ ] records = lookupHostName ( name ) ; return addrFromRecord ( name , records [ 0 ] ) ; } } | Determines the IP address of a host |
40,245 | public static InetAddress [ ] getAllByName ( String name ) throws UnknownHostException { try { InetAddress addr = getByAddress ( name ) ; return new InetAddress [ ] { addr } ; } catch ( UnknownHostException e ) { Record [ ] records = lookupHostName ( name ) ; InetAddress [ ] addrs = new InetAddress [ records . length ]... | Determines all IP address of a host |
40,246 | public static InetAddress getByAddress ( String addr ) throws UnknownHostException { byte [ ] bytes ; bytes = toByteArray ( addr , IPv4 ) ; if ( bytes != null ) return InetAddress . getByAddress ( bytes ) ; bytes = toByteArray ( addr , IPv6 ) ; if ( bytes != null ) return InetAddress . getByAddress ( bytes ) ; throw ne... | Converts an address from its string representation to an IP address . The address can be either IPv4 or IPv6 . |
40,247 | public static InetAddress getByAddress ( String addr , int family ) throws UnknownHostException { if ( family != IPv4 && family != IPv6 ) throw new IllegalArgumentException ( "unknown address family" ) ; byte [ ] bytes ; bytes = toByteArray ( addr , family ) ; if ( bytes != null ) return InetAddress . getByAddress ( by... | Converts an address from its string representation to an IP address in a particular family . |
40,248 | public static int familyOf ( InetAddress address ) { if ( address instanceof Inet4Address ) return IPv4 ; if ( address instanceof Inet6Address ) return IPv6 ; throw new IllegalArgumentException ( "unknown address family" ) ; } | Returns the family of an InetAddress . |
40,249 | public static byte [ ] fromString ( String str ) { ByteArrayOutputStream bs = new ByteArrayOutputStream ( ) ; byte [ ] raw = str . getBytes ( ) ; for ( int i = 0 ; i < raw . length ; i ++ ) { if ( ! Character . isWhitespace ( ( char ) raw [ i ] ) ) bs . write ( raw [ i ] ) ; } byte [ ] in = bs . toByteArray ( ) ; if ( ... | Convert a hex - encoded String to binary data |
40,250 | public void put ( Object o ) throws InterruptedException { synchronized ( lock ) { while ( size == maxSize ) lock . wait ( ) ; elements [ tail ] = o ; if ( ++ tail == maxSize ) tail = 0 ; size ++ ; lock . notify ( ) ; } } | Put object in queue . |
40,251 | public Object get ( ) throws InterruptedException { synchronized ( lock ) { while ( size == 0 ) lock . wait ( ) ; Object o = elements [ head ] ; elements [ head ] = null ; if ( ++ head == maxSize ) head = 0 ; if ( size == maxSize ) lock . notifyAll ( ) ; size -- ; return o ; } } | Get object from queue . Block if there are no objects to get . |
40,252 | public Object peek ( ) throws InterruptedException { synchronized ( lock ) { if ( size == 0 ) lock . wait ( ) ; if ( size == 0 ) return null ; Object o = elements [ head ] ; return o ; } } | Peek at the queue . Block if there are no objects to peek . |
40,253 | public boolean exists ( ) { if ( _exists ) return true ; if ( _urlString . endsWith ( "!/" ) ) { String file_url = _urlString . substring ( 4 , _urlString . length ( ) - 2 ) ; try { return newResource ( file_url ) . exists ( ) ; } catch ( Exception e ) { LogSupport . ignore ( log , e ) ; return false ; } } boolean chec... | Returns true if the respresenetd resource exists . |
40,254 | public UserAgentInfo parse ( String useragent ) throws IOException { UserAgentInfo retObj = new UserAgentInfo ( ) ; if ( useragent == null ) { return retObj ; } useragent = useragent . trim ( ) ; checkDataMaps ( ) ; if ( ! processRobot ( useragent , retObj ) ) { boolean osFound = processBrowserRegex ( useragent , retOb... | Parse the given user agent string and returns a UserAgentInfo object with the related data |
40,255 | private void processOsRegex ( String useragent , UserAgentInfo retObj ) { try { lock . lock ( ) ; for ( Map . Entry < Pattern , Long > entry : osRegMap . entrySet ( ) ) { Matcher matcher = entry . getKey ( ) . matcher ( useragent ) ; if ( matcher . find ( ) ) { Long idOs = entry . getValue ( ) ; OsEntry os = osMap . ge... | Searches in the os regex table . if found a match copies the os data |
40,256 | private boolean processBrowserRegex ( String useragent , UserAgentInfo retObj ) { try { lock . lock ( ) ; boolean osFound = false ; for ( Map . Entry < String , Long > entry : browserRegMap . entrySet ( ) ) { Pattern pattern = Pattern . compile ( entry . getKey ( ) , Pattern . CASE_INSENSITIVE | Pattern . DOTALL ) ; Ma... | Searchs in the browser regex table . if found a match copies the browser data and if possible os data |
40,257 | private void copyType ( UserAgentInfo retObj , Long idBrowser ) { try { lock . lock ( ) ; BrowserEntry be = browserMap . get ( idBrowser ) ; if ( be != null ) { Long type = be . getType ( ) ; if ( type != null ) { String typeString = browserTypeMap . get ( type ) ; if ( typeString != null ) { retObj . setTyp ( typeStri... | Sets the source type if possible |
40,258 | private boolean processRobot ( String useragent , UserAgentInfo retObj ) { try { lock . lock ( ) ; if ( robotsMap . containsKey ( useragent ) ) { retObj . setTyp ( "Robot" ) ; RobotEntry robotEntry = robotsMap . get ( useragent ) ; robotEntry . copyTo ( retObj ) ; if ( robotEntry . getOsId ( ) != null ) { OsEntry os = ... | Checks if the useragent comes from a robot . if yes copies all the data to the result object |
40,259 | public synchronized static SSLSocketFactory getTrustingSSLSocketFactory ( ) { if ( socketFactory != null ) return socketFactory ; TrustManager [ ] trustManagers = new TrustManager [ ] { new TrustEverythingSSLTrustManager ( ) } ; SSLContext sc ; try { sc = SSLContext . getInstance ( "SSL" ) ; sc . init ( null , trustMan... | Returns an SSLSocketFactory that will trust all SSL certificates ; this is suitable for passing to HttpsURLConnection either to its instance method setSSLSocketFactory or to its static method setDefaultSSLSocketFactory . |
40,260 | public static void trustAllSSLCertificates ( HttpsURLConnection connection ) { getTrustingSSLSocketFactory ( ) ; connection . setSSLSocketFactory ( socketFactory ) ; connection . setHostnameVerifier ( new HostnameVerifier ( ) { public boolean verify ( String s , SSLSession sslSession ) { return true ; } } ) ; } | Configures a single HttpsURLConnection to trust all SSL certificates . |
40,261 | private void doit ( String [ ] args ) { try { loadParameters ( args ) ; importKeyPair ( ) ; } catch ( Exception e ) { System . out . println ( "Exception: " + e . getMessage ( ) ) ; e . printStackTrace ( ) ; System . exit ( 23 ) ; } } | Load parameters and perform the import command . Catch any exceptions and clear the password arrays . |
40,262 | private PrivateKey loadPrivateKey ( File privateKeyFile ) throws Exception { System . out . println ( "Loading private key from " + privateKeyFile + ", using " + providerClassName + " as the private key loading provider" ) ; FileInputStream privateKeyInputStream = null ; byte [ ] keyBytes ; try { privateKeyInputStream ... | Load an RSA private key from the given File |
40,263 | public void setFilename ( String filename ) { if ( filename != null ) { filename = filename . trim ( ) ; if ( filename . length ( ) == 0 ) filename = null ; } _filename = filename ; } | Set the log filename . |
40,264 | protected void logExtended ( HttpRequest request , HttpResponse response , Writer log ) throws IOException { String referer = request . getField ( HttpFields . __Referer ) ; if ( referer == null ) log . write ( "\"-\" " ) ; else { log . write ( '"' ) ; log . write ( referer ) ; log . write ( "\" " ) ; } String agent = ... | Log Extended fields . This method can be extended by a derived class to add extened fields to each log entry . It is called by the log method after all standard fields have been added but before the line terminator . Derived implementations should write extra fields to the Writer provided . The default implementation w... |
40,265 | public void setHeaderValue ( String name , String value ) { _fields . put ( name , Collections . singletonList ( value ) ) ; } | Set a header override every response handled will have this header set . |
40,266 | public void setHeaderValues ( String name , String [ ] values ) { _fields . put ( name , Arrays . asList ( values ) ) ; } | Set a multivalued header every response handled will have this header set with the provided values . |
40,267 | public void handle ( String pathInContext , String pathParams , HttpRequest request , HttpResponse response ) throws HttpException , IOException { log . debug ( "SetResponseHeadersHandler.handle()" ) ; for ( Iterator iterator = _fields . entrySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { Map . Entry entry = ( M... | Handle a request by pre - populating the headers from the configured set of _fields . |
40,268 | private Socket createSimulatedSocket ( SSLSocket socket ) { SimulatedSocketFactory . configure ( socket ) ; socket . setEnabledProtocols ( new String [ ] { SSLAlgorithm . SSLv3 . name ( ) , SSLAlgorithm . TLSv1 . name ( ) } ) ; return new SimulatedSSLSocket ( socket , streamManager ) ; } | just an helper function to wrap a normal sslSocket into a simulated one so we can do throttling |
40,269 | protected synchronized void checkDataMaps ( ) throws IOException { if ( lastUpdateCheck == 0 || lastUpdateCheck < System . currentTimeMillis ( ) - updateInterval ) { String versionOnServer = getVersionFromServer ( ) ; if ( currentVersion == null || versionOnServer . compareTo ( currentVersion ) > 0 ) { loadDataFromInte... | This implementation uses a local properties file to keep the lastUpdate time and the local data file version |
40,270 | private void loadDataFromInternetAndSave ( ) throws IOException { InputStream is = null ; FileOutputStream fos = null ; try { URL url = new URL ( DATA_RETRIVE_URL ) ; is = url . openStream ( ) ; fos = new FileOutputStream ( getCacheFile ( ) ) ; byte [ ] buff = new byte [ 1024 * 8 ] ; int len = 0 ; while ( ( len = is . ... | loads the data file from the server and saves it to the local file system |
40,271 | private void saveProperties ( Properties prop ) throws FileNotFoundException , IOException { FileOutputStream fos = new FileOutputStream ( getPropertiesFile ( ) ) ; try { prop . store ( fos , null ) ; } finally { fos . close ( ) ; } } | Saves the properties file to the local filesystem |
40,272 | public synchronized void setInetAddrPort ( InetAddrPort address ) { if ( _address != null && _address . equals ( address ) ) return ; if ( isStarted ( ) ) log . warn ( this + " is started" ) ; _address = address ; } | Set the server InetAddress and port . |
40,273 | public void open ( ) throws IOException { if ( _listen == null ) { _listen = newServerSocket ( _address , _acceptQueueSize ) ; if ( _address == null ) _address = new InetAddrPort ( _listen . getInetAddress ( ) , _listen . getLocalPort ( ) ) ; else { if ( _address . getInetAddress ( ) == null ) _address . setInetAddress... | Open the server socket . This method can be called to open the server socket in advance of starting the listener . This can be used to test if the port is available . |
40,274 | protected void stopJob ( Thread thread , Object job ) { if ( job instanceof Socket ) { try { ( ( Socket ) job ) . close ( ) ; } catch ( Exception e ) { LogSupport . ignore ( log , e ) ; } } super . stopJob ( thread , job ) ; } | Kill a job . This method closes IDLE and socket associated with a job |
40,275 | public Object getValue ( Object name , int i ) { Object l = super . get ( name ) ; if ( i == 0 && LazyList . size ( l ) == 0 ) return null ; return LazyList . get ( l , i ) ; } | Get a value from a multiple value . If the value is not a multivalue then index 0 retrieves the value or null . |
40,276 | public Object put ( Object name , Object value ) { return super . put ( name , LazyList . add ( null , value ) ) ; } | Put and entry into the map . |
40,277 | public void putAll ( Map m ) { Iterator i = m . entrySet ( ) . iterator ( ) ; boolean multi = m instanceof MultiMap ; while ( i . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) i . next ( ) ; if ( multi ) super . put ( entry . getKey ( ) , LazyList . clone ( entry . getValue ( ) ) ) ; else put ( entry . getKey ( )... | Put all contents of map . |
40,278 | public static byte [ ] fromDNS ( byte [ ] sig ) { final int len = 20 ; int n = 0 ; byte rlen , slen , seqlen ; rlen = len ; if ( sig [ 1 ] < 0 ) rlen ++ ; slen = len ; if ( sig [ len + 1 ] < 0 ) slen ++ ; seqlen = ( byte ) ( rlen + slen + 4 ) ; byte [ ] array = new byte [ seqlen + 2 ] ; array [ n ++ ] = ASN1_SEQ ; arra... | Converts the signature field in a SIG record to the format expected by the DSA verification routines . |
40,279 | public void setBufferSize ( int size ) throws IllegalStateException { if ( size <= _bufferSize ) return ; if ( _bufferedOut != null && _bufferedOut . size ( ) > 0 ) throw new IllegalStateException ( "Not Reset" ) ; try { _bufferSize = size ; if ( _bufferedOut != null ) { boolean fixed = _bufferedOut . isFixed ( ) ; _bu... | Set the output buffer size . Note that this is the minimal buffer size and that installed filters may perform their own buffering and are likely to change the size of the output . Also the pre and post reserve buffers may be allocated within the buffer for headers and chunking . |
40,280 | public void resetBuffer ( ) throws IllegalStateException { if ( _out != null && _out != _realOut ) { ArrayList save_observers = _observers ; _observers = null ; _nulled = true ; try { if ( _bufferedOut != null ) { _bufferedOut . resetStream ( ) ; if ( _bufferedOut instanceof ChunkingOutputStream ) ( ( ChunkingOutputStr... | Reset Buffered output . If no data has been committed the buffer output is discarded and the filters may be reinitialized . |
40,281 | public void setChunking ( ) { checkOutput ( ) ; if ( _bufferedOut instanceof ChunkingOutputStream ) ( ( ChunkingOutputStream ) _bufferedOut ) . setChunking ( true ) ; else throw new IllegalStateException ( _bufferedOut . getClass ( ) . toString ( ) ) ; } | Set chunking mode . |
40,282 | public void resetStream ( ) throws IOException , IllegalStateException { if ( isChunking ( ) ) close ( ) ; _out = null ; _nulled = true ; if ( _bufferedOut != null ) { _bufferedOut . resetStream ( ) ; if ( _bufferedOut instanceof ChunkingOutputStream ) ( ( ChunkingOutputStream ) _bufferedOut ) . setChunking ( false ) ;... | Reset the stream . Turn disable all filters . |
40,283 | public void handle ( String pathInContext , String pathParams , HttpRequest request , HttpResponse response ) throws HttpException , IOException { if ( request . getAttribute ( "javax.servlet.error.status_code" ) != null ) return ; try { String ip = request . getRemoteAddr ( ) ; boolean authorized = checkIP ( ip ) ; if... | Handles the incoming request |
40,284 | public void setStandard ( String s ) { s = s . toLowerCase ( ) ; if ( s . indexOf ( "allow" ) > - 1 ) { standard = true ; } else { standard = false ; } } | Set the standard action beeing taken when not registred IPs wants access |
40,285 | private static void main ( String [ ] args ) { IPAccessHandler ipah = new IPAccessHandler ( ) ; ipah . setStandard ( "deny" ) ; ipah . setAllowIP ( "217.215.71.167" ) ; ipah . setDenyIP ( "217.215.71.149" ) ; System . out . println ( ipah . checkIP ( "217.215.71.245" ) + " = false" ) ; System . out . println ( ipah . c... | Main method for testing & debugging . |
40,286 | void setServletPaths ( String servletPath , String pathInfo , ServletHolder holder ) { _servletPath = servletPath ; _pathInfo = pathInfo ; _servletHolder = holder ; } | Set servletpath and pathInfo . Called by the Handler before passing a request to a particular holder to split the context path into a servlet path and path info . |
40,287 | public static ServletHttpRequest unwrap ( ServletRequest request ) { while ( ! ( request instanceof ServletHttpRequest ) ) { if ( request instanceof ServletRequestWrapper ) { ServletRequestWrapper wrapper = ( ServletRequestWrapper ) request ; request = wrapper . getRequest ( ) ; } else throw new IllegalArgumentExceptio... | Unwrap a ServletRequest . |
40,288 | public String getTimeStampStr ( ) { if ( _timeStampStr == null && _timeStamp > 0 ) _timeStampStr = HttpFields . __dateCache . format ( _timeStamp ) ; return _timeStampStr ; } | Get Request TimeStamp |
40,289 | public boolean isHandled ( ) { if ( _handled ) return true ; HttpResponse response = getHttpResponse ( ) ; return ( response != null && response . getState ( ) != HttpMessage . __MSG_EDITABLE ) ; } | Is the request handled . |
40,290 | public void readHeader ( LineInput in ) throws IOException { _state = __MSG_BAD ; org . browsermob . proxy . jetty . util . LineInput . LineBuffer line_buffer ; do { line_buffer = in . readLineBuffer ( ) ; if ( line_buffer == null ) throw new EOFException ( ) ; } while ( line_buffer . size == 0 ) ; if ( line_buffer . s... | Read the request line and header . |
40,291 | public void writeRequestLine ( Writer writer ) throws IOException { writer . write ( _method ) ; writer . write ( ' ' ) ; writer . write ( _uri != null ? _uri . toString ( ) : "null" ) ; writer . write ( ' ' ) ; writer . write ( _version ) ; } | Write the HTTP request line as it was received . |
40,292 | public String getScheme ( ) { String scheme = _uri . getScheme ( ) ; if ( scheme == null && _connection != null ) scheme = _connection . getDefaultScheme ( ) ; return scheme == null ? "http" : scheme ; } | Get the request Scheme . The scheme is obtained from an absolute URI . If the URI in the request is not absolute then the connections default scheme is returned . If there is no connection http is returned . |
40,293 | public String getHost ( ) { if ( _host != null ) return _host ; _host = _uri . getHost ( ) ; _port = _uri . getPort ( ) ; if ( _host != null ) return _host ; _hostPort = _header . get ( HttpFields . __Host ) ; _host = _hostPort ; _port = 0 ; if ( _host != null && _host . length ( ) > 0 ) { int colon = _host . lastIndex... | Get the request host . |
40,294 | public int getPort ( ) { if ( _port > 0 ) return _port ; if ( _host != null ) return 0 ; if ( _uri . isAbsolute ( ) ) _port = _uri . getPort ( ) ; else if ( _connection != null ) _port = _connection . getServerPort ( ) ; return _port ; } | Get the request port . The port is obtained either from an absolute URI the HTTP Host header field the connection or the default . |
40,295 | Object forceRemoveField ( String name ) { int saved_state = _state ; try { _state = __MSG_EDITABLE ; return removeField ( name ) ; } finally { _state = saved_state ; } } | Force a removeField . This call ignores the message state and forces a field to be removed from the request . It is required for the handling of the Connection field . |
40,296 | public List getAcceptableTransferCodings ( ) { if ( _dotVersion < 1 ) return null ; if ( _te != null ) return _te ; Enumeration tenum = getFieldValues ( HttpFields . __TE , HttpFields . __separators ) ; if ( tenum != null ) { List te = HttpFields . qualityList ( tenum ) ; int size = te . size ( ) ; if ( size > 0 ) { Ob... | Get the acceptable transfer encodings . The TE field is used to construct a list of acceptable extension transfer codings in quality order . An empty list implies that only chunked is acceptable . A null list implies that no transfer coding can be applied . |
40,297 | public String getParameter ( String name ) { if ( ! _paramsExtracted ) extractParameters ( ) ; return ( String ) _parameters . getValue ( name , 0 ) ; } | Get a parameter value . |
40,298 | void recycle ( HttpConnection connection ) { _method = null ; _host = null ; _hostPort = null ; _port = 0 ; _te = null ; if ( _parameters != null ) _parameters . clear ( ) ; _paramsExtracted = false ; _handled = false ; _cookiesExtracted = false ; _timeStamp = 0 ; _timeStampStr = null ; _authUser = null ; _authType = n... | Recycle the request . |
40,299 | public void destroy ( ) { _parameters = null ; _method = null ; _uri = null ; _host = null ; _hostPort = null ; _te = null ; _cookies = null ; _lastCookies = null ; _timeStampStr = null ; _userPrincipal = null ; _authUser = null ; _authUser = null ; if ( _attributes != null ) _attributes . clear ( ) ; super . destroy (... | Destroy the request . Help the garbage collector by null everything that we can . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.