Package com.mastfrog.url

Examples of com.mastfrog.url.URL


            this.send100Continue = HttpClient.this.send100continue;
        }

        @Override
        public ResponseFuture execute(ResponseHandler<?> r) {
            URL u = getURL();
            HttpRequest req = build();
            if (userAgent != null) {
                req.headers().add(HttpHeaders.Names.USER_AGENT, userAgent);
            }
            if (compress) {
View Full Code Here


    public HttpRequest build() {
        if (url == null) {
            throw new IllegalStateException("URL not set");
        }
        URL u = getURL();
        String uri = u.getPathAndQuery();
        if (uri.isEmpty()) {
            uri = "/";
        }
        HttpMethod mth = HttpMethod.valueOf(method.name());
        DefaultHttpRequest h = body == null
                ? new DefaultHttpRequest(version, mth, uri)
                : new DefaultFullHttpRequest(version, mth, uri, body);
        for (Entry<?> e : entries) {
            e.addTo(h.headers());
        }
        if (!noHostHeader) {
            h.headers().add(HttpHeaders.Names.HOST, u.getHost().toString());
        }
        if (!h.headers().contains(HttpHeaders.Names.CONNECTION) && !noConnectionHeader) {
            h.headers().add(HttpHeaders.Names.CONNECTION, "close");
        }
        if (!noDateHeader) {
View Full Code Here

        this.errorHandler = errorHandler;
        return this;
    }

    void decorate(HttpRequest req) {
        URL url;
        if (!req.getUri().contains("://")) {
            String host = req.headers().get(Headers.HOST.name());
            url = URL.builder().setPath(req.getUri()).setHost(host).create();
        } else {
            url = URL.parse(req.getUri());
        }
        Lock readLock = lock.readLock();
        readLock.lock();
        try {
            List<Cookie> toSend = new ArrayList<>();
            for (Cookie cookie : cookies) {
                if (checkDomain) {
                    if (cookie.getDomain() != null && !cookie.getDomain().equals(url.getHost().toString())) {
                        continue;
                    }
                }
                if (checkPath) {
                    String pth = cookie.getPath();
                    if (pth != null) {
                        String compare = url.getPath().toStringWithLeadingSlash();
                        if (!"/".equals(pth) && !"".equals(pth) && !compare.equals(pth) && !compare.startsWith(pth)) {
                            continue;
                        }
                    }
                }
View Full Code Here

                String hdr = URLDecoder.decode(msg.headers().get(HttpHeaders.Names.LOCATION), "UTF-8");
                if (hdr != null) {
                    if (hdr.toLowerCase().startsWith("http://") || hdr.toLowerCase().startsWith("https://")) {
                        return hdr;
                    } else {
                        URL orig = info.url;
                        String pth = orig.getPath() == null ? "/" : URLDecoder.decode(orig.getPath().toString(), "UTF-8");
                        if (hdr.startsWith("/")) {
                            pth = hdr;
                        } else {
                            if (pth.endsWith("/")) {
                                pth += hdr;
                            } else {
                                pth += "/" + hdr;
                            }
                        }
                        StringBuilder sb = new StringBuilder(orig.getProtocol().toString());
                        sb.append("://").append(orig.getHost());
                        if (!orig.getProtocol().getDefaultPort().equals(orig.getPort())) {
                            sb.append(":").append(orig.getPort());
                        }
                        if (pth.charAt(0) != '/') {
                            sb.append('/');
                        }
                        sb.append(pth);
View Full Code Here

TOP

Related Classes of com.mastfrog.url.URL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.