create WaybackRequet for Replay request.
@param url target URL
@param replay requested date
@param start start timestamp (14-digit)
@param end end timestamp (14-digit)
@return WaybackRequet
170535
public static WaybackRequest createReplayRequest(String url, String replay, String start, String end) {
		WaybackRequest r = new WaybackRequest();
		r.setReplayRequest();
		r.setRequestUrl(url);
		r.setReplayTimestamp(replay);
		r.setStartTimestamp(start);
		r.setEndTimestamp(end);
		return r;
	}
554555
public String generate(String url) {
        long expiration = this.expiration;
        if (expiration == 0) {
            if (duration > 0) {
                final long start = startTime > 0 ? startTime : Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis() / 1000L;
                expiration = start + duration;
            } else {
                throw new IllegalArgumentException("Must provide either expiration or duration");
            }
        }
        ArrayList<String> tokenParts = new ArrayList<String>();
        if (ip != null) {
            tokenParts.add("ip=" + ip);
        }
        if (startTime > 0) {
            tokenParts.add("st=" + startTime);
        }
        tokenParts.add("exp=" + expiration);
        if (acl != null) {
            tokenParts.add("acl=" + escapeToLower(acl));
        }
        ArrayList<String> toSign = new ArrayList<String>(tokenParts);
        if (url != null && acl == null) {
            toSign.add("url=" + escapeToLower(url));
        }
        String auth = digest(StringUtils.join(toSign, "~"));
        tokenParts.add("hmac=" + auth);
        return tokenName + "=" + StringUtils.join(tokenParts, "~");

    }
714570
public void setRecordRoute(boolean rr) {
		if(started) {
			throw new IllegalStateException("Cannot set a record route on an already started proxy");
		}
		if(rr) {
			Message message = null;
			if(originalRequest != null) {
				message = originalRequest.getMessage();
			}
			// record route should be based on the original received message
			javax.sip.address.SipURI flowUri= originalRequest.getSipSession().getFlow();
			if(flowUri != null) {				
				this.recordRouteURIString = flowUri.toString();
				if(logger.isDebugEnabled())
					logger.debug("Using Session Flow URI as record route URI " + recordRouteURIString);
			} else {
				this.recordRouteURIString = JainSipUtils.createRecordRouteURI( sipFactoryImpl.getSipNetworkInterfaceManager(), message).toString();
			}
			if(logger.isDebugEnabled()) {
				logger.debug("Record routing enabled for proxy, Record Route used will be : " + recordRouteURIString);
			}
		}		
		this.recordRoutingEnabled = rr;

	}
958274
public static URLEntity createUrlEntity(int start, int end, String url, String expandedURL, String displayURL) {
        return new URLEntityJSONImpl(start, end, url, expandedURL, displayURL);
    }
637134
private void maybeOpenAndSend(final CouchbaseRequest request) {
        LOGGER.debug(logIdent(hostname, PooledService.this)
                + "Need to open a new Endpoint (current size {})", endpoints.size());

        final Endpoint endpoint = endpointFactory.create(
            hostname, bucket, username, password, port, ctx
        );

        synchronized (epMutex) {
            endpoints.add(endpoint);
            endpointStates.register(endpoint, endpoint);
        }

        final Subscription subscription = whenState(endpoint, LifecycleState.CONNECTED,
            new Action1<LifecycleState>() {
                @Override
                public void call(LifecycleState lifecycleState) {
                    if (disconnect) {
                        RetryHelper.retryOrCancel(env, request, responseBuffer);
                    } else {
                        endpoint.send(request);
                        endpoint.send(SignalFlush.INSTANCE);
                    }
                }
            }
        );

        endpoint.connect().subscribe(new Subscriber<LifecycleState>() {
            @Override
            public void onCompleted() {
                // ignored on purpose
            }

            @Override
            public void onError(Throwable e) {
                unsubscribeAndRetry(subscription, request);
            }

            @Override
            public void onNext(LifecycleState state) {
                if (state == LifecycleState.DISCONNECTING || state == LifecycleState.DISCONNECTED) {
                    unsubscribeAndRetry(subscription, request);
                }
            }
        });
    }
372642
public WaybackRequest parse(HttpServletRequest httpRequest, 
		AccessPoint wbContext) throws BadQueryException {
		
		WaybackRequest wbRequest = null;
		@SuppressWarnings("unchecked")
		Map<String,String[]> queryMap = httpRequest.getParameterMap();
		String query = AccessPoint.getMapParam(queryMap, SEARCH_QUERY);
		if (query == null) {
			return null;
		}
		wbRequest = new WaybackRequest();
		
		String base = wbContext.translateRequestPath(httpRequest);
		if (base.startsWith(REPLAY_BASE)) {
			wbRequest.setReplayRequest();
		} else if(base.startsWith(QUERY_BASE)){
			wbRequest.setCaptureQueryRequest();
		} else if(base.startsWith(XQUERY_BASE)){
			wbRequest.setCaptureQueryRequest();
			wbRequest.setXMLMode(true);
			
		} else {
			return null;
		}
		
		String numResults = AccessPoint.getMapParam(queryMap, SEARCH_RESULTS);
		String startPage = AccessPoint.getMapParam(queryMap, START_PAGE);

		if (numResults != null) {
			int nr = Integer.parseInt(numResults);
			wbRequest.setResultsPerPage(nr);
		} else {
			wbRequest.setResultsPerPage(getMaxRecords());
		}
		if (startPage != null) {
			int sp = Integer.parseInt(startPage);
			wbRequest.setPageNum(sp);
		} else {
			wbRequest.setPageNum(1);
		}

		// first try the entire line_tokens:
		for (int i = 0; i < lineTokens.length; i++) {
			String token = lineTokens[i] + ":";
			int index = query.indexOf(token);
			if (index > -1) {
				// found it, take value as the remainder of the query
				String value = query.substring(index + token.length());
				// TODO: trim trailing whitespace?
				wbRequest.put(lineTokens[i], value);
				query = query.substring(0, index);
			}
		}

		// now split whatever is left on whitespace:
		String[] parts = WHITESPACE_PATTERN.split(query);
		for (int i = 0; i < parts.length; i++) {
			String token = parts[i];
			int colonIndex = token.indexOf(":");
			if (colonIndex == -1) {
				throw new BadQueryException("Bad search token(" + token + ")");
			}
			try {
				String key = URLDecoder.decode(token.substring(0, colonIndex),
						"UTF-8");
				String value = URLDecoder.decode(
						token.substring(colonIndex + 1), "UTF-8");
				// TODO: make sure key is in singleTokens?
				// let's just let em all thru for now:
				wbRequest.put(key, value);
			} catch (UnsupportedEncodingException e) {
				throw new BadQueryException("Unsupported encoding: UTF-8");
			}
		}
		if (wbRequest.getStartTimestamp() == null) {
			wbRequest.setStartTimestamp(getEarliestTimestamp());
		}
		if (wbRequest.getEndTimestamp() == null) {
			wbRequest.setEndTimestamp(getLatestTimestamp());
		}

		return wbRequest;
	}
115460
@Override
    public void replayCompletion(String globalId) {
        if (rc == null) {
            // Find a factory to create the RecoveryCoordinator
            try {
                rc = getRecoveryCoordinator();
            } catch (RecoveryCoordinatorNotAvailableException e) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "replayCompletion", e);
            }
        }

        if (rc != null) {
            rc.replayCompletion(globalId);
        }
    }
615611
Map<Object, Object> createOrRestoreMap(FacesContext context, String prefix,
        boolean create)
    {
        ExternalContext external = context.getExternalContext();
        Map<String, Object> sessionMap = external.getSessionMap();

        Map<Object, Object> map = (Map<Object, Object>) sessionMap.get(prefix);
        if (map == null && create)
        {
            map = new ConcurrentHashMap<Object, Object>();
            sessionMap.put(prefix, map);
        }
        return map;
    }
115331
public void goToURL(String url) {
        String action = "Loading " + url;
        String expected = "Loaded " + url;
        double start = System.currentTimeMillis();
        try {
            driver.get(url);
        } catch (Exception e) {
            log.warn(e);
            reporter.fail(action, expected, "Fail to Load " + url + ". " + e.getMessage());
            return;
        }
        double timeTook = System.currentTimeMillis() - start;
        timeTook = timeTook / 1000;
        reporter.pass(action, expected, "Loaded " + url + " in " + timeTook + SECONDS);
        acceptCertificate();
    }
662507
public void start(String[] args) throws Exception {
        OptionParserCommandLine commandLineArgs = new OptionParserCommandLine();
        options = commandLineArgs.parse(args);
        if (options == null) {
            // Abort
            return;
        }
        startup = commandLineArgs.startup();
        // initialize editor settings
        configEditor();
        // initialize JShell instance
        try {
            resetState();
        } catch (IllegalStateException ex) {
            // Display just the cause (not a exception backtrace)
            cmderr.println(ex.getMessage());
            //abort
            return;
        }
        // Read replay history from last jshell session into previous history
        replayableHistoryPrevious = ReplayableHistory.fromPrevious(prefs);
        // load snippet/command files given on command-line
        for (String loadFile : commandLineArgs.nonOptions()) {
            runFile(loadFile, "jshell");
        }
        // if we survived that...
        if (regenerateOnDeath) {
            // initialize the predefined feedback modes
            initFeedback(commandLineArgs.feedbackMode());
        }
        // check again, as feedback setting could have failed
        if (regenerateOnDeath) {
            // if we haven't died, and the feedback mode wants fluff, print welcome
            if (feedback.shouldDisplayCommandFluff()) {
                hardmsg("jshell.msg.welcome", version());
            }
            // Be sure history is always saved so that user code isn't lost
            Thread shutdownHook = new Thread() {
                @Override
                public void run() {
                    replayableHistory.storeHistory(prefs);
                }
            };
            Runtime.getRuntime().addShutdownHook(shutdownHook);
            // execute from user input
            try (IOContext in = new ConsoleIOContext(this, cmdin, console)) {
                while (regenerateOnDeath) {
                    if (!live) {
                        resetState();
                    }
                    run(in);
                }
            } finally {
                replayableHistory.storeHistory(prefs);
                closeState();
                try {
                    Runtime.getRuntime().removeShutdownHook(shutdownHook);
                } catch (Exception ex) {
                    // ignore, this probably caused by VM aready being shutdown
                    // and this is the last act anyhow
                }
            }
        }
        closeState();
    }
200767
private void initializeRetireJsRepo(Settings settings, URL repoUrl) throws UpdateException {
        try {
            final File dataDir = settings.getDataDirectory();
            final File tmpDir = settings.getTempDirectory();
            boolean useProxy = false;
            if (null != settings.getString(Settings.KEYS.PROXY_SERVER)) {
                useProxy = true;
                LOGGER.debug("Using proxy");
            }
            LOGGER.debug("RetireJS Repo URL: {}", repoUrl.toExternalForm());
            final URLConnectionFactory factory = new URLConnectionFactory(settings);
            final HttpURLConnection conn = factory.createHttpURLConnection(repoUrl, useProxy);
            final String filename = repoUrl.getFile().substring(repoUrl.getFile().lastIndexOf("/") + 1, repoUrl.getFile().length());
            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                final File tmpFile = new File(tmpDir, filename);
                final File repoFile = new File(dataDir, filename);
                try (InputStream inputStream = conn.getInputStream();
                        FileOutputStream outputStream = new FileOutputStream(tmpFile)) {
                    IOUtils.copy(inputStream, outputStream);
                }
                //using move fails if target and destination are on different disks which does happen (see #1394 and #1404)
                Files.copy(tmpFile.toPath(), repoFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
                if (!tmpFile.delete()) {
                    tmpFile.deleteOnExit();
                }
            }
        } catch (IOException e) {
            throw new UpdateException("Failed to initialize the RetireJS repo", e);
        }
    }
952833
def start_record():
    
    global record, playback, current
    if record:
        raise StateError("Already recording.")
    if playback:
        raise StateError("Currently playing back.")
    record = True
    current = ReplayData()
    install(RecordingHTTPConnection, RecordingHTTPSConnection)
838734
public void restartListener(String _url) {
    if (getConfig().setListenerURL(_url)) {
      if (_server != null)
        _server.shutdownNow();
      try {
        startListener();
      } catch (IOException | URISyntaxException e) {
        Console.severe("Unable to start services.");
        e.printStackTrace();
      }
    }
  }
986915
@Override
    public String getCompleteURL() {
        ServletRESTRequestImpl ret = castRequest();
        if (ret != null)
            return ret.getCompleteURL();
        return null;
    }
71019
@Override
    @RequestMapping(value = "/return", method = RequestMethod.GET)
    public String returnEndpoint(Model model, HttpServletRequest request,
                                 final RedirectAttributes redirectAttributes,
                                 @PathVariable Map<String, String> pathVars) throws PaymentException {
        if (request.getParameter(MessageConstants.CHECKOUT_COMPLETE) != null) {
            request.setAttribute(MessageConstants.CHECKOUT_COMPLETE, true);
        }
        String path = super.process(model, request, redirectAttributes);
        if (isAjaxRequest(request) && StringUtils.startsWith(path, baseRedirect)) {
            return StringUtils.replace(path, baseRedirect, "ajaxredirect:");
        }
        return path;
    }
310367
public static DestinationUrl createDestinationUrl(String destination) {
        String[] split = splitDestination(destination);
        String host = split[0].trim();
        String jmsDestination = split[1].trim();
        return new DestinationUrl(host, jmsDestination);
    }
348825
public ResponseBuilder getTimeMapBuilder(final SortedSet<Instant> mementos, final TrellisRequest req,
            final String baseUrl) {

        final List<MediaType> acceptableTypes = req.getAcceptableMediaTypes();
        final String identifier = fromUri(baseUrl).path(req.getPath()).build().toString();
        final List<Link> links = getMementoLinks(identifier, mementos).collect(toList());

        final ResponseBuilder builder = ok().link(identifier, ORIGINAL + " " + TIMEGATE);
        builder.links(links.stream().map(this::filterLinkParams).toArray(Link[]::new))
            .link(Resource.getIRIString(), TYPE).link(RDFSource.getIRIString(), TYPE)
            .header(ALLOW, join(",", GET, HEAD, OPTIONS));

        final RDFSyntax syntax = getSyntax(trellis.getIOService(), acceptableTypes, APPLICATION_LINK_FORMAT);

        if (syntax != null) {
            final IRI profile = getProfile(acceptableTypes, syntax);
            final IRI jsonldProfile = profile != null ? profile : compacted;

            final StreamingOutput stream = new StreamingOutput() {
                @Override
                public void write(final OutputStream out) throws IOException {
                    trellis.getIOService().write(timemap.asRdf(identifier, links), out, syntax, jsonldProfile);
                }
            };

            return builder.type(syntax.mediaType()).entity(stream);
        }

        return builder.type(APPLICATION_LINK_FORMAT)
            .entity(links.stream().map(this::filterLinkParams).map(Link::toString).collect(joining(",\n")) + "\n");
    }