Examples of RequestHeader


Examples of net.yacy.cora.protocol.RequestHeader

            path = path.substring(0, argpos);
        }

        // set up virtual connection properties to call httpdFileHander.doGet()
        final HashMap<String, Object> conProp = new HashMap<String, Object>();
        final RequestHeader header = new RequestHeader(HTTPDemon.reverseMappingCache);
        conProp.put(HeaderFramework.CONNECTION_PROP_METHOD, HeaderFramework.METHOD_GET);
        conProp.put(HeaderFramework.CONNECTION_PROP_PATH, path);
        conProp.put(HeaderFramework.CONNECTION_PROP_ARGS, args);
        conProp.put(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);
        conProp.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, requesthost);
        header.put(RequestHeader.AUTHORIZATION, authorization);
        HTTPDFileHandler.doGet(conProp, header, out);
    }
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

            // parsing the http request line
            final HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_GET, arg, session);
           
            // we now know the HTTP version. depending on that, we read the header           
            String httpVersion = (String) prop.get(HeaderFramework.CONNECTION_PROP_HTTP_VER); if (httpVersion == null) httpVersion = HeaderFramework.HTTP_VERSION_0_9;
            final RequestHeader header = (httpVersion.equals(HeaderFramework.HTTP_VERSION_0_9))
                    ? new RequestHeader(reverseMappingCache)
                    : readHeader(prop, session);
           
            // handling transparent proxy support
            handleTransparentProxySupport(header, prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);
           
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

        try {
            final HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_HEAD, arg, session);
           
            // we now know the HTTP version. depending on that, we read the header
            String httpVersion = (String) prop.get(HeaderFramework.CONNECTION_PROP_HTTP_VER); if (httpVersion == null) httpVersion = HeaderFramework.HTTP_VERSION_0_9;
            final RequestHeader header = (httpVersion.equals(HeaderFramework.HTTP_VERSION_0_9))
                    ? new RequestHeader(reverseMappingCache)
                    : readHeader(prop,session);
           
            // handle transparent proxy support
            handleTransparentProxySupport(header, prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);
           
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

        try {
            final HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_POST, arg, session);
           
            // we now know the HTTP version. depending on that, we read the header
            String httpVersion = (String) prop.get(HeaderFramework.CONNECTION_PROP_HTTP_VER); if (httpVersion == null) httpVersion = HeaderFramework.HTTP_VERSION_0_9;
            final RequestHeader header = (httpVersion.equals(HeaderFramework.HTTP_VERSION_0_9))
                    ? new RequestHeader(reverseMappingCache)
                    : readHeader(prop, session);
           
            // handle transfer-coding
            final InputStream sessionIn;
            final String transferEncoding = header.get(HeaderFramework.TRANSFER_ENCODING);
            if (transferEncoding != null) {
                if (!HeaderFramework.HTTP_VERSION_1_1.equals(httpVersion)) {
                    log.logWarning("client "+ session.getName() +" uses transfer-coding with HTTP version "+ httpVersion +"!");
                }
                if("chunked".equalsIgnoreCase(header.get(HeaderFramework.TRANSFER_ENCODING))) {
                    sessionIn = new ChunkedInputStream(session.in);
                } else {
                    // "A server which receives an entity-body with a transfer-coding it does
                    // not understand SHOULD return 501 (Unimplemented), and close the
                    // connection." [RFC 2616, section 3.6]
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

        prop.put(HeaderFramework.CONNECTION_PROP_PATH, "/");
        prop.put(HeaderFramework.CONNECTION_PROP_EXT, "");
        prop.put(HeaderFramework.CONNECTION_PROP_URL, "");       
       
        // parse remaining lines
        final RequestHeader header = readHeader(prop,session);              
       
        if (!(allowProxy(session))) {
            // not authorized through firewall blocking (ip does not match filter)         
            session.out.write(UTF8.getBytes(httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + session.userAddress.getHostAddress() + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING));
            return serverCore.TERMINATE_CONNECTION;
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

   

    public static RequestHeader readHeader(final HashMap<String, Object> prop, final serverCore.Session theSession) throws IOException {
       
        // reading all headers
        final RequestHeader header = new RequestHeader(HTTPDemon.reverseMappingCache);
        int p;
        String line;
        while ((line = theSession.readLineAsString()) != null) {
            if (line.length() == 0) break; // this separates the header of the HTTP request from the body
            // parse the header line: a property separated with the ':' sign
            if ((p = line.indexOf(':')) >= 0) {
                // store a property
                header.add(line.substring(0, p).trim(), line.substring(p + 1).trim());
            }
        }
       
        /*
         * doing some header validation here ...
         */
        String httpVersion = (String) prop.get(HeaderFramework.CONNECTION_PROP_HTTP_VER); if (httpVersion == null) httpVersion = "HTTP/0.9";
        if (httpVersion.equals("HTTP/1.1") && !header.containsKey(HeaderFramework.HOST)) {
            // the HTTP/1.1 specification requires that an HTTP/1.1 server must reject any 
            // HTTP/1.1 message that does not contain a Host header.           
            HTTPDemon.sendRespondError(prop,theSession.out,0,400,null,null,null);
            throw new IOException("400 Bad request");
        }    
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

        return log;
    }
   
    private Iterator<String> downloadSeedFile(final DigestURI seedURL) throws IOException {
        // Configure http headers
        final RequestHeader reqHeader = new RequestHeader();
        reqHeader.put(HeaderFramework.PRAGMA, "no-cache");
        reqHeader.put(HeaderFramework.CACHE_CONTROL, "no-cache"); // httpc uses HTTP/1.0 is this necessary?
        reqHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.getUserAgent());
       
        final HTTPClient client = new HTTPClient();
        client.setHeader(reqHeader.entrySet());
        byte[] content = null;
        try {
            // send request
          content = client.GETbytes(seedURL);
        } catch (final Exception e) {
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

     */
    public File downloadRelease() {
        final File storagePath = Switchboard.getSwitchboard().releasePath;
        File download = null;
        // setup httpClient
        final RequestHeader reqHeader = new RequestHeader();
        reqHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.getUserAgent());

        final String name = getUrl().getFileName();
        byte[] signatureBytes = null;

        final HTTPClient client = new HTTPClient();
        client.setTimout(6000);
        client.setHeader(reqHeader.entrySet());

        // download signature first, if public key is available
        try {
            if (this.publicKey != null) {
              final byte[] signatureData = client.GETbytes(getUrl().toString() + ".sig");
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

        return da;
    }
   
    public static SitemapReader parse(final DigestURI sitemapURL) throws IOException {
        // download document
        final RequestHeader requestHeader = new RequestHeader();
        requestHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.getUserAgent());
        final HTTPClient client = new HTTPClient();
        client.setTimout(5000);
        client.setHeader(requestHeader.entrySet());
        try {
            client.GET(sitemapURL.toString());
            if (client.getStatusCode() != 200) {
                throw new IOException("Unable to download the sitemap file " + sitemapURL +
                        "\nServer returned status: " + client.getHttpResponse().getStatusLine());
View Full Code Here

Examples of net.yacy.cora.protocol.RequestHeader

        Iterator<String>   enu;
        int                lc;
        final int          sc = this.peers.sizeConnected();
        ResponseHeader header;

        final RequestHeader reqHeader = new RequestHeader();
        reqHeader.put(HeaderFramework.PRAGMA, "no-cache");
        reqHeader.put(HeaderFramework.CACHE_CONTROL, "no-cache");
        reqHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.getUserAgent());
        final HTTPClient client = new HTTPClient();
        client.setHeader(reqHeader.entrySet());
        client.setTimout((int) getConfigLong("bootstrapLoadTimeout", 20000));

        yacyCore.log.logInfo("BOOTSTRAP: " + sc + " seeds known from previous run");

        // - use the superseed to further fill up the seedDB
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.