/** * Strips the fragment identifier (if any) from the Url. */ static String trimFragment( String rawUrl ) { if (isJavaScriptURL( rawUrl )) return rawUrl; final int hashIndex = rawUrl.indexOf( '#' ); return hashIndex < 0 ? rawUrl: rawUrl.substring( 0, hashIndex ); }
/** * Strips the fragment identifier (if any) from the Url. */ static String trimFragment( String rawUrl ) { if (isJavaScriptURL( rawUrl )) return rawUrl; final int hashIndex = rawUrl.indexOf( '#' ); return hashIndex < 0 ? rawUrl: rawUrl.substring( 0, hashIndex ); }
/** * Strips the fragment identifier (if any) from the Url. */ static String trimFragment( String rawUrl ) { if (isJavaScriptURL( rawUrl )) return rawUrl; final int hashIndex = rawUrl.indexOf( '#' ); return hashIndex < 0 ? rawUrl: rawUrl.substring( 0, hashIndex ); }
/** * Returns the URL relative to the current page which will handle the request. */ String getRelativePage() { final String url = getRelativeURL(); if (HttpUnitUtils.isJavaScriptURL( url )) return url; final int questionMarkIndex = url.indexOf("?"); if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) { return url.substring(0, questionMarkIndex); } return url; }
/** * Returns the URL relative to the current page which will handle the request. */ String getRelativePage() { final String url = getRelativeURL(); if (HttpUnitUtils.isJavaScriptURL( url )) return url; final int questionMarkIndex = url.indexOf("?"); if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) { return url.substring(0, questionMarkIndex); } return url; }
/** * Returns the URL relative to the current page which will handle the request. */ String getRelativePage() { final String url = getRelativeURL(); if (HttpUnitUtils.isJavaScriptURL( url )) return url; final int questionMarkIndex = url.indexOf("?"); if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) { return url.substring(0, questionMarkIndex); } return url; }
/** * Gets all parameters from a URL **/ private String getParametersString() { String url = HttpUnitUtils.trimFragment( getDestination() ); if (url.trim().length() == 0) url = getBaseURL().toExternalForm(); if (HttpUnitUtils.isJavaScriptURL( url )) return ""; final int questionMarkIndex = url.indexOf("?"); if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) { return url.substring( questionMarkIndex + 1 ); } return ""; }
/** * Gets all parameters from a URL **/ private String getParametersString() { String url = HttpUnitUtils.trimFragment( getDestination() ); if (url.trim().length() == 0) url = getBaseURL().toExternalForm(); if (HttpUnitUtils.isJavaScriptURL( url )) return ""; final int questionMarkIndex = url.indexOf("?"); if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) { return url.substring( questionMarkIndex + 1 ); } return ""; }
/** * Gets all parameters from a URL **/ private String getParametersString() { String url = HttpUnitUtils.trimFragment( getDestination() ); if (url.trim().length() == 0) url = getBaseURL().toExternalForm(); if (HttpUnitUtils.isJavaScriptURL( url )) return ""; final int questionMarkIndex = url.indexOf("?"); if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) { return url.substring( questionMarkIndex + 1 ); } return ""; }
/** * Returns the resource specified by the request. Does not update the window or load included framesets. * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. */ public WebResponse getResource( WebRequest request ) throws IOException { _client.tellListeners( request ); WebResponse response = null; String urlString = request.getURLString().trim(); FrameSelector targetFrame = _frameContents.getTargetFrame( request ); if (urlString.startsWith( "about:" )) { response = new DefaultWebResponse( _client, targetFrame, null, "" ); } else if (!HttpUnitUtils.isJavaScriptURL( urlString )) { response = _client.createResponse( request, targetFrame ); } else { ScriptingHandler handler = request.getSourceScriptingHandler(); if (handler == null) handler = getCurrentPage().getScriptingHandler(); Object result = handler.evaluateExpression( urlString ); if (result != null) { response = new DefaultWebResponse( _client, targetFrame, request.getURL(), result.toString() ); } } if (response != null) _client.tellListeners( response ); return response; }
/** * Returns the resource specified by the request. Does not update the window or load included framesets. * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. */ public WebResponse getResource( WebRequest request ) throws IOException { _client.tellListeners( request ); WebResponse response = null; String urlString = request.getURLString().trim(); FrameSelector targetFrame = _frameContents.getTargetFrame( request ); if (urlString.startsWith( "about:" )) { response = new DefaultWebResponse( _client, targetFrame, null, "" ); } else if (!HttpUnitUtils.isJavaScriptURL( urlString )) { response = _client.createResponse( request, targetFrame ); } else { ScriptingHandler handler = request.getSourceScriptingHandler(); if (handler == null) handler = getCurrentPage().getScriptingHandler(); Object result = handler.evaluateExpression( urlString ); if (result != null) { response = new DefaultWebResponse( _client, targetFrame, request.getURL(), result.toString() ); } } if (response != null) _client.tellListeners( response ); return response; }
/** * Returns the resource specified by the request. Does not update the window or load included framesets. * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. */ public WebResponse getResource( WebRequest request ) throws IOException { _client.tellListeners( request ); WebResponse response = null; String urlString = request.getURLString().trim(); FrameSelector targetFrame = _frameContents.getTargetFrame( request ); if (urlString.startsWith( "about:" )) { response = new DefaultWebResponse( _client, targetFrame, null, "" ); } else if (!HttpUnitUtils.isJavaScriptURL( urlString )) { response = _client.createResponse( request, targetFrame ); } else { ScriptingHandler handler = request.getSourceScriptingHandler(); if (handler == null) handler = getCurrentPage().getScriptingHandler(); Object result = handler.evaluateExpression( urlString ); if (result != null) { response = new DefaultWebResponse( _client, targetFrame, request.getURL(), result.toString() ); } } if (response != null) _client.tellListeners( response ); return response; }