Package org.owasp.webscarab.model

Examples of org.owasp.webscarab.model.Response


        public void run() {
          HTTPClient client = HTTPClientFactory.getInstance().getHTTPClient();
            while (_running) {
                Request request = getNextRequest();
                try {
                    Response response = client.fetchResponse(request);
                    response.flushContentStream();
                    responseReceived(response);
                } catch (IOException ioe) {
                    requestError(request, ioe);
                }
            }
View Full Code Here


                        buff.append("; ").append(cookies[i].getName()).append("=").append(cookies[i].getValue());
                    }
                    request.setHeader("Cookie", buff.toString());
                }
            }
            Response response = _in.fetchResponse(request);
            if (_readResponses && response != null) {
                NamedValue[] headers = response.getHeaders();
                for (int i=0; i<headers.length; i++) {
                    if (headers[i].getName().equalsIgnoreCase("Set-Cookie") || headers[i].getName().equalsIgnoreCase("Set-Cookie2")) {
                        Cookie cookie = new Cookie(new Date(), request.getURL(), headers[i].getValue());
                        _model.addCookie(cookie);
                    }
View Full Code Here

                _logger.info("Creating a new Fetcher");
                hc = getHTTPClient();
                _clientList.add(hc);
            }
        }
        Response response = null;
        IOException ioe = null;
        try {
            response = hc.fetchResponse(request);
        } catch (IOException e) {
            ioe = e;
View Full Code Here

                            if (te.getTarget() instanceof IOException) {
                                throw (IOException) te.getTarget();
                            }
                            throw te;
                       }
                        Response response = (Response) _interpreter.get("response");
                        _interpreter.unset("model");
                        _interpreter.unset("response");
                        _interpreter.unset("nextClient");
                        _interpreter.unset("request");
                        response.setHeader("X-BeanShell", "possibly modified");
                        return response;
                    }
                } catch (EvalError e) {
                    System.err.println("e is a " + e.getClass());
                    if (_ui != null) _ui.getErr().println(e.toString());
View Full Code Here

            public void actionPerformed(ActionEvent e) {
                Object o = baseComboBox.getSelectedItem();
                if (o instanceof ConversationID) {
                    ConversationID id = (ConversationID) o;
                    ConversationModel cModel = _model.getConversationModel();
                    Response response = cModel.getResponse(id);
                    String cType = response.getHeader("Content-Type");
                    if (cType == null || !cType.startsWith("text")) {
                        JOptionPane.showMessageDialog(ComparePanel.this, "Selected conversation is not text", "Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    byte[] content = response.getContent();
                    if (content == null || content.length == 0) {
                        JOptionPane.showMessageDialog(ComparePanel.this, "Selected conversation has no content", "Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    _compare.setBaseConversation(null, id);
                    _base = new String(content);
                }
            }
        });
       
        conversationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent evt) {
                int selected = conversationTable.getSelectedRow();
                _diffPanel.clear();
                if (selected == -1) {
                    return;
                }
                selected = _conversationSorter.modelIndex(selected);
                ConversationModel cmodel = _model.getComparisonModel();
               
                ConversationID id = cmodel.getConversationAt(selected);
                Response response = cmodel.getResponse(id);
                String contentType = response.getHeader("Content-Type");
                if (contentType == null || !contentType.startsWith("text")) {
                    JOptionPane.showMessageDialog(ComparePanel.this, "Selected conversation is not text", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                byte[] content = response.getContent();
                if (content == null || content.length == 0) {
                    JOptionPane.showMessageDialog(ComparePanel.this, "Selected conversation has no content", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                final String dst = new String(content);
View Full Code Here

                            }
                        }
                    }
                }
            }
            Response response = _in.fetchResponse(request);
            if (_interceptResponse) {
                String contentType = response.getHeader("Content-Type");
                if (contentType == null || ! _content.matcher(contentType).matches()) {
                    return response;
                }
                if (_ui != null) {
                    request = response.getRequest();
                    response = _ui.editResponse(request, response);
                    if (response == null) throw new IOException("Response aborted in Manual Edit");
                    if (response.getRequest() == null) response.setRequest(request);
                    response.addHeader("X-ManualEdit", "possibly modified");
                }
            }
            return response;
        }
View Full Code Here

    public Request getRequest() {
        return new Request(_request); // protective copy
    }
   
    public Response getResponse() {
        return new Response(_response); // protective copy
    }
View Full Code Here

                //Runs on the event-dispatching thread.
                public void finished() {
                    Object obj = getValue();
                    if (obj instanceof Response) {
                        Response response = (Response) getValue();
                        if (response != null) {
                            _responsePanel.setResponse(response);
                            String name = nameTextField.getText();
                            String regex = regexTextField.getText();
                            try {
View Full Code Here

                    id = _selected;
                    _model.setBusy(true);
                    HttpUrl baseUrl = cmodel.getRequestUrl(id);
                    if (baseUrl.getQuery() != null)
                      baseUrl = baseUrl.getParentUrl();
                    Response baseResponse = cmodel.getResponse(id);
                    byte[] baseBytes = baseResponse.getContent();
                    String type = baseResponse.getHeader("Content-Type");
                    if (type == null || !type.startsWith("text")) {
                        _logger.warning("Base response is not text, skipping!");
                        return;
                    }
                    List baseline = tokenize(baseBytes);
                    _diff = new LevenshteinDistance(baseline);
                   
                    count = cmodel.getConversationCount();
                    _logger.info("Checking " + count + " conversaitons");
                    for (int i=0; i<count; i++) {
                        ConversationID cid = cmodel.getConversationAt(i);
                        HttpUrl curl = cmodel.getRequestUrl(cid);
                        if (curl.getQuery() != null)
                          curl = curl.getParentUrl();
                        if (!curl.equals(baseUrl))
                          continue;
                        _logger.info("Checking conversation " + i + " == " + cid);
                        if (cid.equals(id)) {
                            _model.setDistance(cid, 0);
                        } else {
                            Response response = cmodel.getResponse(cid);
                            String ctype = response.getHeader("Content-Type");
                            _logger.info("Content-type is " + ctype);
                            if (ctype != null && ctype.startsWith("text")) {
                                byte[] bytes = response.getContent();
                                List target = tokenize(bytes);
                                _model.setDistance(cid, _diff.getDistance(target));
                            }
                        }
                    }
View Full Code Here

                    if (_analysisQueue.size()>0)
                        id = (ConversationID) _analysisQueue.remove(0);
                }
                if (id != null) {
                    Request request = _model.getRequest(id);
                    Response response = _model.getResponse(id);
                    String origin = _model.getConversationOrigin(id);
                    Iterator it = _plugins.iterator();
                    while (it.hasNext()) {
                        Plugin plugin = (Plugin) it.next();
                        if (plugin.isRunning()) {
View Full Code Here

TOP

Related Classes of org.owasp.webscarab.model.Response

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.