Example usage for org.apache.commons.httpclient URI setPath

List of usage examples for org.apache.commons.httpclient URI setPath

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URI setPath.

Prototype

public void setPath(String path) throws URIException 

Source Link

Document

Set the path.

Usage

From source file:org.parosproxy.paros.core.scanner.VariantURLPath.java

/**
 *
 * @param msg/*from   w w  w.j  av a2s .  c  om*/
 * @param originalPair
 * @param name
 * @param value
 * @param escaped
 * @return
 */
private String setParameter(HttpMessage msg, NameValuePair originalPair, String name, String value,
        boolean escaped) {
    try {
        URI uri = msg.getRequestHeader().getURI();
        String[] paths = msg.getRequestHeader().getURI().getPath().toString().split("/");

        if (originalPair.getPosition() < paths.length) {

            String encodedValue = (escaped) ? value : getEscapedValue(value);

            paths[originalPair.getPosition()] = encodedValue;
            String path = StringUtils.join(paths, "/");

            try {
                uri.setEscapedPath(path);

            } catch (URIException e) {
                // Looks like it wasnt escaped after all
                uri.setPath(path);
            }
        }

    } catch (URIException e) {
        logger.error(e.getMessage(), e);
    }

    return value;
}

From source file:org.zaproxy.zap.extension.soap.WSDLCustomParser.java

private static void persistMessage(final HttpMessage message, final String opDisplayName) {
    // Add the message to the history panel and sites tree
    final HistoryReference historyRef;

    try {/*  w ww.j a va 2s  . c  o  m*/
        historyRef = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_ZAP_USER,
                message);
    } catch (Exception e) {
        LOG.warn(e.getMessage(), e);
        return;
    }

    final ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader()
            .getExtension(ExtensionHistory.class);
    if (extHistory != null) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                extHistory.addHistory(historyRef);

                // FIXME
                /*
                 * Modifies the URI adding the SOAP operation name to avoid overwrites. It's
                 * done after saving it in history so that the original URI is preserved for
                 * scanning tasks.
                 *
                 * URI modification solution is only a workaround since it has size limitations
                 * and, anyway, it is not an elegant solution.
                 */
                try {
                    URI soapURI = message.getRequestHeader().getURI();
                    String soapStringURI = soapURI.getPath();
                    soapURI.setPath(soapStringURI + opDisplayName);
                } catch (URIException e) {
                    LOG.warn(e.getMessage(), e);
                }
                Model.getSingleton().getSession().getSiteTree().addPath(historyRef, message);
            }
        });
    }
}