Search in sources :

Example 1 with Request

use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.

the class FailedConnectionThread method run.

public void run() {
    Request request = new Request(monitor, IProtocolAdapter.TCPIP_PROTOCOL_ID, monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
    String err = error;
    if (err == null)
        err = Messages.errorConnectToServer;
    request.addToResponse(err.getBytes());
    try {
        InputStream in = socket.getInputStream();
        byte[] b = new byte[BUFFER];
        while (in.available() > 0) {
            int n = in.read(b);
            byte[] c = new byte[n];
            System.arraycopy(b, 0, c, 0, n);
            request.addToRequest(c);
        }
    } catch (Exception e) {
    // ignore
    } finally {
        try {
            socket.shutdownInput();
            socket.shutdownOutput();
            socket.close();
        } catch (Exception ex) {
        // ignore
        }
    }
}
Also used : InputStream(java.io.InputStream) Request(org.eclipse.wst.internet.monitor.core.internal.provisional.Request)

Example 2 with Request

use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.

the class ModifyMessageAction method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
public void run(IAction action) {
    if (selection != null) {
        Object element = ((StructuredSelection) selection).getFirstElement();
        if (element != null && element instanceof Request) {
            Request req = (Request) element;
            ResendHTTPRequest newReq = MonitorManager.createResendRequest(req);
            MonitorManager.getInstance().addResendRequest(req, newReq);
            TreeViewer treeViewer = MonitorView.view.treeViewer;
            treeViewer.add(req, newReq);
            treeViewer.setSelection(new StructuredSelection(newReq), false);
        }
    }
}
Also used : ResendHTTPRequest(org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Request(org.eclipse.wst.internet.monitor.core.internal.provisional.Request) ResendHTTPRequest(org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest)

Example 3 with Request

use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.

the class ResendMessageAction method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
public void run(IAction action) {
    if (selection != null) {
        Object element = ((StructuredSelection) selection).getFirstElement();
        if (element != null && element instanceof Request) {
            Request req = (Request) element;
            ResendHTTPRequest newReq = MonitorManager.createResendRequest(req);
            MonitorManager.getInstance().addResendRequest(req, newReq);
            TreeViewer treeViewer = MonitorView.view.treeViewer;
            treeViewer.add(req, newReq);
            treeViewer.setSelection(new StructuredSelection(newReq), false);
            newReq.sendRequest();
        }
    }
}
Also used : ResendHTTPRequest(org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Request(org.eclipse.wst.internet.monitor.core.internal.provisional.Request) ResendHTTPRequest(org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest)

Example 4 with Request

use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.

the class HTTPThread method parseHeader.

/**
 * Parse an HTTP header.
 *
 * @throws IOException
 */
public void parseHeader() throws IOException {
    if (Trace.PARSING) {
        Trace.trace(Trace.STRING_PARSING, "Parsing header for: " + this);
    }
    // read until first blank line
    boolean isFirstLine = true;
    boolean isNew = true;
    byte[] b = readLine();
    while (b.length > 5) {
        if (Trace.PARSING) {
            Trace.trace(Trace.STRING_PARSING, "Parsing header line: '" + new String(b) + "'");
        }
        if (isFirstLine) {
            String s = new String(b);
            if (isRequest) {
                setLabel(s);
                isNew = false;
            }
            if (!isRequest) {
                int index1 = s.indexOf(' ');
                int index2 = s.indexOf(' ', index1 + 1);
                try {
                    responseType = s.substring(index1 + 1, index2).trim();
                    if (Trace.PARSING) {
                        Trace.trace(Trace.STRING_PARSING, "Response Type: " + this + " " + responseType);
                    }
                } catch (Exception e) {
                    if (Trace.PARSING) {
                        Trace.trace(Trace.STRING_PARSING, "Error parsing response type for: " + this, e);
                    }
                }
                if (responseType != null && responseType.equals("100")) {
                    outputBytes(b, isNew);
                    isNew = false;
                    b = readLine();
                    outputBytes(b, false);
                    b = readLine();
                    index1 = s.indexOf(' ');
                    index2 = s.indexOf(' ', index1 + 1);
                    try {
                        responseType = s.substring(index1 + 1, index2).trim();
                        if (Trace.PARSING) {
                            Trace.trace(Trace.STRING_PARSING, "Response Type: " + this + " " + responseType);
                        }
                    } catch (Exception e) {
                        if (Trace.PARSING) {
                            Trace.trace(Trace.STRING_PARSING, "Error parsing response type for: " + this, e);
                        }
                    }
                }
            }
            isFirstLine = false;
        }
        // translate
        b = translateHeaderLine(b);
        outputBytes(b, isNew);
        isNew = false;
        b = readLine();
    }
    if (Trace.PARSING) {
        Trace.trace(Trace.STRING_PARSING, "Parsing final header line: '" + new String(b) + "'");
    }
    outputBytes(b, false);
    Request rr = conn.getRequestResponse(isRequest);
    if (Trace.PARSING) {
        Trace.trace(Trace.STRING_PARSING, "Setting header length: " + rr.getRequest(Request.ALL).length);
    }
    setHTTPHeader(rr);
}
Also used : Request(org.eclipse.wst.internet.monitor.core.internal.provisional.Request)

Example 5 with Request

use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.

the class MonitorTreeContentProvider method getParent.

/*
	 * Returns the parent for the given element, or <code>null</code> 
	 * indicating that the parent can't be computed. 
	 */
public Object getParent(Object element) {
    if (element != null) {
        if (element instanceof Integer)
            return ROOT;
        Request call = (Request) element;
        if (call instanceof ResendHTTPRequest) {
            ResendHTTPRequest callResend = (ResendHTTPRequest) call;
            Request parent = callResend.getOriginalRequest();
            if (parent != null)
                return parent;
        }
        return new Integer(call.getLocalPort());
    }
    return null;
}
Also used : ResendHTTPRequest(org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest) Request(org.eclipse.wst.internet.monitor.core.internal.provisional.Request) ResendHTTPRequest(org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest)

Aggregations

Request (org.eclipse.wst.internet.monitor.core.internal.provisional.Request)12 ResendHTTPRequest (org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest)6 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 ArrayList (java.util.ArrayList)2 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 List (java.util.List)1 GroupMarker (org.eclipse.jface.action.GroupMarker)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SashForm (org.eclipse.swt.custom.SashForm)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1