Package org.parosproxy.paros.network

Examples of org.parosproxy.paros.network.HttpBody


    }
  }
 
  protected void processHttp(HttpRequestHeader requestHeader, boolean isSecure) throws IOException {

    HttpBody reqBody = null;
    boolean isFirstRequest = true;
    HttpMessage msg = null;
       
        if (isRecursive(requestHeader)) {
            throw new IOException("Recursive request to proxy itself stopped.");
View Full Code Here


  private Vector getFormQuery(Form form, URI baseURI) {
    Vector qryStrList  = new Vector();
    Vector qryList    = new Vector();
    String queryString = "";
    HttpRequestHeader reqHeader = null;
    HttpBody reqBody = null;
   
    if (form.getAction()==null) {
        return qryList;
    }
   
    int combinationCount = 1;
    for (int i=0; i<form.getSelect().length; i++) {
        // restrict max # of options to 2
      combinationCount *= (form.getSelect()[i].getOption().length > 2) ? 2: form.getSelect()[i].getOption().length;
    }

    if (combinationCount > 512) {
      return qryList;
    }

    try {
      // build all queryString using input tags
      for (int i=0; i<form.getInput().length; i++) {
        Input input = form.getInput()[i];
                if (input.getName()== null || input.getName().length() == 0) {
                    continue;
                }
        if (input.getType() != null) {
          if (//input.getType().equalsIgnoreCase(Input.SUBMIT) ||
                           
                        // submit field should also be sent for better crawling.
                           
            input.getType().equalsIgnoreCase(Input.PASSWORD) ||
            input.getType().equalsIgnoreCase(Input.CHECKBOX) ||
            input.getType().equalsIgnoreCase(Input.RESET)) {
            continue;
          }
        }
        String value = input.getValue();
        if (input.getType().equalsIgnoreCase(Input.TEXT) && value.equals("")) {
            // arbitrary fill a "1" for displayable fields.
            value = "1";
        }
                queryString = buildPostQueryString(queryString, input.getName(), value);
      }

            // build all queryString using textarea tags
            for (int i=0; i<form.getTextArea().length; i++) {
                TextArea textarea = form.getTextArea()[i];
                if (textarea.getName()== null || textarea.getName().length() == 0) {
                    continue;
                }
                String value = textarea.getValue();
                queryString = buildPostQueryString(queryString, textarea.getName(), value);
            }
           
      // build all queryString using SELECT and OPTION tags
      qryStrList.addElement(queryString);
      for (int i=0; i<form.getSelect().length;i++) {
        Select select = form.getSelect()[i];
                if (select.getName()== null || select.getName().length() == 0) {
                    continue;
                }
        qryStrList = addSelectField(qryStrList, select);
      }

      for (int i=0; i<qryStrList.size(); i++) {
          HttpMessage msg = null;
        URI uri = null;
        String qryStr = (String) qryStrList.elementAt(i);
        if (form.getMethod().equalsIgnoreCase(Form.GET)) {
            String action = (form.getAction().indexOf(QUESTION) <0) ? form.getAction()+QUESTION+qryStr : form.getAction()+AMPERSAND+qryStr;           
          uri = new URI(baseURI, action, true);
          reqHeader = new HttpRequestHeader(form.getMethod().trim().toUpperCase(), uri, HttpHeader.HTTP11);
          msg = new HttpMessage(reqHeader);
        } else if (form.getMethod().equalsIgnoreCase(Form.POST)) {
                   
                    if (!parent.getParent().getSpiderParam().isPostForm()) {
                        continue;
                    }
            uri = new URI(baseURI, form.getAction(), true);
            reqHeader = new HttpRequestHeader(form.getMethod().trim().toUpperCase(), uri, HttpHeader.HTTP11);
            reqBody = new HttpBody(qryStr);
            reqHeader.setContentLength(reqBody.length());
            msg = new HttpMessage(reqHeader, reqBody);
        } else {
            continue;
        }
        msg.getRequestHeader().setContentLength(msg.getRequestBody().length());
View Full Code Here

    }
  }
 
  protected void processHttp(HttpRequestHeader requestHeader, boolean isSecure) throws IOException {

    HttpBody reqBody = null;
    boolean isFirstRequest = true;
    HttpMessage msg = null;
       
        if (isRecursive(requestHeader)) {
            throw new IOException("Recursive request to proxy itself stopped.");
View Full Code Here

  private Vector<HttpMessage> getFormQuery(Form form, URI baseURI) {
    Vector<String> qryStrList = new Vector<String>();
    Vector<HttpMessage> qryList = new Vector<HttpMessage>();
    String queryString = "";
    HttpRequestHeader reqHeader = null;
    HttpBody reqBody = null;

    if (form.getAction() == null) {
      return qryList;
    }

    int combinationCount = 1;
    for (int i = 0; i < form.getSelect().length; i++) {
      // restrict max # of options to 2
      combinationCount *= (form.getSelect()[i].getOption().length > 2) ? 2
          : form.getSelect()[i].getOption().length;
    }

    if (combinationCount > 512) {
      return qryList;
    }

    try {
      // build all queryString using input tags
      for (int i = 0; i < form.getInput().length; i++) {
        Input input = form.getInput()[i];
        if (input.getName() == null || input.getName().length() == 0) {
          continue;
        }
        if (input.getType() != null) {
          if (// input.getType().equalsIgnoreCase(Input.SUBMIT) ||

          // submit field should also be sent for better crawling.

          input.getType().equalsIgnoreCase(Input.PASSWORD)
              || input.getType().equalsIgnoreCase(Input.CHECKBOX)
              || input.getType().equalsIgnoreCase(Input.RESET)) {
            continue;
          }
        }
        String value = input.getValue();
        if (input.getType().equalsIgnoreCase(Input.TEXT)
            && value.equals("")) {
          // arbitrary fill a "1" for displayable fields.
          value = "1";
        }
        queryString = buildPostQueryString(queryString,
            input.getName(), value);
      }

      // build all queryString using textarea tags
      for (int i = 0; i < form.getTextArea().length; i++) {
        TextArea textarea = form.getTextArea()[i];
        if (textarea.getName() == null
            || textarea.getName().length() == 0) {
          continue;
        }
        String value = textarea.getValue();
        queryString = buildPostQueryString(queryString, textarea
            .getName(), value);
      }

      // build all queryString using SELECT and OPTION tags
      qryStrList.addElement(queryString);
      for (int i = 0; i < form.getSelect().length; i++) {
        Select select = form.getSelect()[i];
        if (select.getName() == null || select.getName().length() == 0) {
          continue;
        }
        qryStrList = addSelectField(qryStrList, select);
      }

      for (int i = 0; i < qryStrList.size(); i++) {
        HttpMessage msg = null;
        URI uri = null;
        String qryStr = (String) qryStrList.elementAt(i);
        if (form.getMethod().equalsIgnoreCase(Form.GET)) {
          String action = (form.getAction().indexOf(QUESTION) < 0) ? form
              .getAction()
              + QUESTION + qryStr
              : form.getAction() + AMPERSAND + qryStr;
          uri = new URI(baseURI, action, true);
          reqHeader = new HttpRequestHeader(form.getMethod().trim()
              .toUpperCase(), uri, HttpHeader.HTTP11);
          msg = new HttpMessage(reqHeader);
        } else if (form.getMethod().equalsIgnoreCase(Form.POST)) {

          if (!parent.getParent().getSpiderParam().isPostForm()) {
            continue;
          }
          uri = new URI(baseURI, form.getAction(), true);
          reqHeader = new HttpRequestHeader(form.getMethod().trim()
              .toUpperCase(), uri, HttpHeader.HTTP11);
          reqBody = new HttpBody(qryStr);
          reqHeader.setContentLength(reqBody.length());
          msg = new HttpMessage(reqHeader, reqBody);
        } else {
          continue;
        }
        msg.getRequestHeader().setContentLength(
View Full Code Here

TOP

Related Classes of org.parosproxy.paros.network.HttpBody

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.