Examples of ResponseHeader


Examples of com.derbysoft.spitfire.fastjson.dto.ResponseHeader

    }

    public GenericRS<HotelAvailRS> createTest() {
        GenericRS<HotelAvailRS> rs = new GenericRS<HotelAvailRS>();
        rs.setHeader(new ResponseHeader("dsfsdfsd"));
        HotelAvailRS hotelAvailRS = createExpectedHotelAvailRS();
        TPAExtensionsDTO extensions = new TPAExtensionsDTO();
        extensions.getElements().put("dfd", "Dfdf");
        hotelAvailRS.setTpaExtensions(extensions);
        rs.setPayload(hotelAvailRS);
View Full Code Here

Examples of com.volantis.vdp.scs.util.ResponseHeader

    /**
     * Receives the response from the server. The method is processed in separate thread
     */
    public void run() {
        try {
            ResponseHeader response;
            boolean run = true;

            while(!this.isInterrupted()) {
                String headerBuffer = "";
                String line = "";

                while( dataIn.available() == 0 ) {
                    if(System.currentTimeMillis() -
                            lastTime > keepalive ) {
                        clientBroker.close();
                        run = false;
                        break;
                    }
                    Thread.sleep(100);
                }
                if( !run ) break;

                while((line = readLine()).length() > 0) {
                    headerBuffer += line + ConstData.EMPTY_LINE;
                }
                response = new ResponseHeader(headerBuffer);
                clientBroker.send(response.getBytes());

                if(response.getContentLength() > 0) {
                    readBytes(response.getContentLength(), null);
                } else if(response.getTransfEncoding().
                    equalsIgnoreCase("chunked")) {
                    int numberBytes = 0;

                    while((line = readLine()).length() ==0 ) {}

                    while(!((numberBytes =
                            Integer.parseInt(line, 16)) == 0)) {
                        readBytes(numberBytes, line);
                        while((line = readLine()).length() ==0 ) {}
                    }
                }

                String connection = response.getConnection();
                if(connection.equalsIgnoreCase("close")) {
                    clientBroker.close();
                } else if(connection.equalsIgnoreCase("keep-alive")) {
                    this.keepalive = response.getKeepAliveTimeout();
                    this.lastTime = System.currentTimeMillis();
                    socket.setKeepAlive(true);
                    clientBroker.setKeepAlive(true);
                }
            }
View Full Code Here

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

Examples of net.yacy.cora.protocol.ResponseHeader

          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

Examples of net.yacy.cora.protocol.ResponseHeader

            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

Examples of net.yacy.cora.protocol.ResponseHeader

            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

Examples of net.yacy.cora.protocol.ResponseHeader

                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

Examples of net.yacy.cora.protocol.ResponseHeader

            }

            // 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

Examples of net.yacy.cora.protocol.ResponseHeader

            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

Examples of net.yacy.cora.protocol.ResponseHeader

            // 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
TOP
Copyright © 2018 www.massapi.com. 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.