Logo Search packages:      
Sourcecode: jaminid version File versions  Download package

void com::prolixtech::jaminid::Request::addRequestLines ( String  requestMessage  )  [inline]

Method Adds Request Lines

Parameters:
requestMessage the message to add

Definition at line 175 of file Request.java.

References appendToBody(), com::prolixtech::jaminid::Daemon::printlog(), and setMethodLine().

Referenced by com::prolixtech::jaminid::Connection::run().

                                                       {
        if (this.currentStatus == Request.STATUS_COMPLETE) {
            return;
        }

        if (this.currentStatus == Request.STATUS_MALFORMED)
            return;

        this.requestMessageBuffer.append(requestMessage);

        int bodyIndex = requestMessage.indexOf("\r\n\r\n");
        String reqBody = "";

        /*
         * if(bodyIndex>0){ reqBody = requestMessage.substring(bodyIndex+4);
         * requestMessage = requestMessage.substring(0, bodyIndex); }
         */

        StringTokenizer tokenizer = new java.util.StringTokenizer(
                requestMessage, "\n\r");

        if (this.currentStatus == Request.STATUS_WAITING_FOR_METHOD) {
            currentStatus = Request.STATUS_WAITING_FOR_PARAMS;
            setMethodLine(tokenizer.nextToken());
            // process first line
        }

        if (this.currentStatus == Request.STATUS_WAITING_FOR_PARAMS) {

            while (tokenizer.hasMoreTokens()) {
                String token = tokenizer.nextToken();

                int splitLocation = token.indexOf(":");
                if (splitLocation > 0) {

                    String key = (token.substring(0, splitLocation)).trim();
                    String value = (token.substring(splitLocation + 1)).trim();
                    masterDaemon.printlog("KEY [" + key + "] VAL [" + value
                            + "]");

                    this.activeHeader.put(key, value);
                } else {
                    // "Not a keyval pair: " + token;
                }
            }

        }

        if (this.currentStatus == Request.STATUS_WAITING_FOR_BODY) {
            reqBody = requestMessage;
        }
        if (bodyIndex > 0) {
            this.currentStatus = Request.STATUS_WAITING_FOR_BODY;
        }
        if (this.currentStatus == Request.STATUS_WAITING_FOR_BODY) {
            this.appendToBody(reqBody);
        }

        masterDaemon.printlog("[**] METHOD: " + this.HTTPMethod);
        masterDaemon.printlog("[**] URI: " + this.requestURI);
        int lastDotLoc = requestURI.lastIndexOf(".");
        if (lastDotLoc != -1) {
            masterDaemon.printlog("[**] TYPE: "
                    + Protocol.getMIME(requestURI.substring(lastDotLoc)));
        }
        masterDaemon.printlog("[**] BODY: " + requestBody);
    }


Generated by  Doxygen 1.6.0   Back to index