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
}
}
}
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);
}
}
}
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();
}
}
}
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);
}
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;
}
Aggregations