Package net.yacy.cora.protocol

Examples of net.yacy.cora.protocol.ResponseHeader


        if (header.get("EXT", "html").equals("png")) {
            // a png was requested
            return ImageParser.parse(u, resource);
        } else {
            // get response header and set mime type
            ResponseHeader responseHeader = Cache.getResponseHeader(url.hash());
            String resMime = responseHeader == null ? null : responseHeader.mime();
            if (resMime != null) {
                final ResponseHeader outgoingHeader = new ResponseHeader();
                outgoingHeader.put(HeaderFramework.CONTENT_TYPE, resMime);
                prop.setOutgoingHeader(outgoingHeader);
            }       
   
            // add resource
            prop.put("resource", resource);
View Full Code Here


          prop.put("jsonp-end", "");
        }

        // Adding CORS Access header for yacysearch.rss output
        if (rss) {
            final ResponseHeader outgoingHeader = new ResponseHeader();
            outgoingHeader.put(HeaderFramework.CORS_ALLOW_ORIGIN, "*");
            prop.setOutgoingHeader(outgoingHeader);
        }

        // collect search attributes
        final boolean newsearch =post.hasValue("query") && post.hasValue("former") && !post.get("query","").equalsIgnoreCase(post.get("former","")); //new search term
View Full Code Here

            prop.putHTML("query", originalquerystring);
        }

        // Adding CORS Access header for xml output
        if (xml) {
            final ResponseHeader outgoingHeader = new ResponseHeader();
            outgoingHeader.put(HeaderFramework.CORS_ALLOW_ORIGIN, "*");
            prop.setOutgoingHeader(outgoingHeader);
        }
       
        // return rewrite properties
        return prop;
View Full Code Here

            return prop;
        }
       
        final servletProperties prop = new servletProperties();
        if (post.containsKey("act") && "clear_cookie".equals(post.get("act"))) {
            final ResponseHeader outgoingHeader = new ResponseHeader();
            final Iterator<Map.Entry<String, String>> it = header.entrySet().iterator();
            Map.Entry<String, String> e;
            while (it.hasNext()) {
                e = it.next();
                if ("Cookie".equals(e.getKey())) {
                    final String cookies[] = e.getValue().split(";");
                    for(final String cookie : cookies)
                    {
                        final String nameValue[] = cookie.split("=");
                        outgoingHeader.setCookie(nameValue[0].trim(),nameValue.length>1 ? (nameValue[1].trim()) : "","Thu, 01-Jan-99 00:00:01 GMT");
                    }
                }
            }
         
            prop.setOutgoingHeader(outgoingHeader);
            prop.put("coockiesout", "0");
            //header.
        
        } else if (post.containsKey("act") && "set_cookie".equals(post.get("act"))) {
            final String cookieName = post.get("cookie_name").trim();
            final String cookieValue = post.get("cookie_value").trim();
            final ResponseHeader outgoingHeader = new ResponseHeader();

            outgoingHeader.setCookie(cookieName,cookieValue);
            prop.setOutgoingHeader(outgoingHeader);
            prop.put("cookiesin", "1");
            prop.putHTML("cookiesin_0_name", cookieName);
            prop.putHTML("cookiesin_0_value", cookieValue);
            //header.
View Full Code Here

                cookie=sb.userDB.getCookie(entry);
            else if(staticAdmin)
                cookie=sb.userDB.getAdminCookie();
               
            if(entry != null || staticAdmin){
                final ResponseHeader outgoingHeader=new ResponseHeader();
                outgoingHeader.setCookie("login", cookie);
                prop.setOutgoingHeader(outgoingHeader);
               
                prop.put("logged-in", "1");
                prop.put("logged-in_identified-by", "1");
                prop.putHTML("logged-in_username", username);
View Full Code Here

            }

            // handle outgoing cookies
            handleOutgoingCookies(requestHeader, host, ip);
            prepareRequestHeader(conProp, requestHeader, hostlow);
            ResponseHeader cachedResponseHeader = Cache.getResponseHeader(url.hash());
           
            // why are files unzipped upon arrival? why not zip all files in cache?
            // This follows from the following premises
            // (a) no file shall be unzip-ed more than once to prevent unnecessary computing time
            // (b) old cache entries shall be comparable with refill-entries to detect/distinguish case 3+4
            // (c) the indexing mechanism needs files unzip-ed, a schedule could do that later
            // case b and c contradicts, if we use a scheduler, because files in a stale cache would be unzipped
            // and the newly arrival would be zipped and would have to be unzipped upon load. But then the
            // scheduler is superfluous. Therefore the only reminding case is
            // (d) cached files shall be either all zipped or unzipped
            // case d contradicts with a, because files need to be unzipped for indexing. Therefore
            // the only remaining case is to unzip files right upon load. Thats what we do here.
           
            // finally use existing cache if appropriate
            // here we must decide weather or not to save the data
            // to a cache
            // we distinguish four CACHE STATE cases:
            // 1. cache fill
            // 2. cache fresh - no refill
            // 3. cache stale - refill - necessary
            // 4. cache stale - refill - superfluous
            // in two of these cases we trigger a scheduler to handle newly arrived files:
            // case 1 and case 3
            if (cachedResponseHeader == null) {
                if (log.isFinest()) log.logFinest(reqID + " page not in cache: fulfill request from web");
                    fulfillRequestFromWeb(conProp, url, requestHeader, cachedResponseHeader, countedRespond);
            } else {
              final Request request = new Request(
                  null,
                        url,
                        requestHeader.referer() == null ? null : new DigestURI(requestHeader.referer()).hash(),
                        "",
                        cachedResponseHeader.lastModified(),
                        sb.crawler.defaultProxyProfile.handle(),
                        0,
                        0,
                        0,
                        0);
View Full Code Here

            try {
              client.GET(getUrl);
                if (log.isFinest()) log.logFinest(reqID +"    response status: "+ client.getHttpResponse().getStatusLine());
                conProp.put(HeaderFramework.CONNECTION_PROP_CLIENT_REQUEST_HEADER, requestHeader);

                final ResponseHeader responseHeader = new ResponseHeader(client.getHttpResponse().getAllHeaders());
                // determine if it's an internal error of the httpc
                if (responseHeader.isEmpty()) {
                  throw new Exception(client.getHttpResponse().getStatusLine().toString());
                }

                final ChunkedOutputStream chunkedOut = setTransferEncoding(conProp, responseHeader, client.getHttpResponse().getStatusLine().getStatusCode(), respond);

                // the cache does either not exist or is (supposed to be) stale
                long sizeBeforeDelete = -1;
                if (cachedResponseHeader != null) {
                    // delete the cache
                    ResponseHeader rh = Cache.getResponseHeader(url.hash());
                    if (rh != null && (sizeBeforeDelete = rh.getContentLength()) == 0) {
                        byte[] b = Cache.getContent(url.hash());
                        if (b != null) sizeBeforeDelete = b.length;
                    }
                    Cache.delete(url);
                    conProp.put(HeaderFramework.CONNECTION_PROP_PROXY_RESPOND_CODE, "TCP_REFRESH_MISS");
View Full Code Here

            // determine if it's an internal error of the httpc
//            final ResponseHeader responseHeader = res.getResponseHeader();
//            if (responseHeader.isEmpty()) {
//                throw new Exception(res.getStatusLine());
//            }     
            final ResponseHeader responseHeader = new ResponseHeader(client.getHttpResponse().getAllHeaders());
            if (responseHeader.isEmpty()) {
                throw new Exception(client.getHttpResponse().getStatusLine().toString());
            }
           
//            prepareResponseHeader(responseHeader, res.getHttpVer());
            prepareResponseHeader(responseHeader, client.getHttpResponse().getStatusLine().getProtocolVersion().toString());
View Full Code Here

            try {
              // sending the request
              client.POST(getUrl, body, contentLength);
              if (log.isFinest()) log.logFinest(reqID +"    response status: "+ client.getHttpResponse().getStatusLine());
             
              final ResponseHeader responseHeader = new ResponseHeader(client.getHttpResponse().getAllHeaders());
              // determine if it's an internal error of the httpc
              if (responseHeader.isEmpty()) {
                throw new Exception(client.getHttpResponse().getStatusLine().toString());
              }                                 
             
              final ChunkedOutputStream chunked = setTransferEncoding(conProp, responseHeader, client.getHttpResponse().getStatusLine().getStatusCode(), countedRespond);
             
              prepareResponseHeader(responseHeader, client.getHttpResponse().getProtocolVersion().toString());
             
              // sending the respond header back to the client
              if (chunked != null) {
                  responseHeader.put(HeaderFramework.TRANSFER_ENCODING, "chunked");
              }
             
              // sending response headers
              if (log.isFinest()) log.logFinest(reqID +"    sending response header: "+ responseHeader);
              HTTPDemon.sendRespondHeader(conProp,
View Full Code Here

        if (ProxySettings.use && ProxySettings.use4ssl) {
          final HTTPClient remoteProxy = setupHttpClient(requestHeader, host);
   
            try {
              remoteProxy.HEADResponse("http://" + host + ":" + port);
              ResponseHeader header = new ResponseHeader(remoteProxy.getHttpResponse().getAllHeaders());
             
                // outputs a logline to the serverlog with the current status
              log.logInfo("CONNECT-RESPONSE: status=" + remoteProxy.getHttpResponse().getStatusLine() + ", header=" + header.toString());
              final boolean success = remoteProxy.getHttpResponse().getStatusLine().getStatusCode() >= 200 && remoteProxy.getHttpResponse().getStatusLine().getStatusCode() <= 399;
                if (success) {
                    // replace connection details
                    host = ProxySettings.host;
                    port = ProxySettings.port;
View Full Code Here

TOP

Related Classes of net.yacy.cora.protocol.ResponseHeader

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.