Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-11-04 04:43:14 -0500
committerSimone Bordet2015-11-04 04:45:01 -0500
commit2a765afdc63c12c3371c1defc73c88eaf948842f (patch)
tree6d15b5213c57bc126162edc4bea5425e7b50f09b
parentc63ef3e08b3eeb4065adea1ff84d5d7730e6b3e0 (diff)
downloadorg.eclipse.jetty.project-2a765afdc63c12c3371c1defc73c88eaf948842f.tar.gz
org.eclipse.jetty.project-2a765afdc63c12c3371c1defc73c88eaf948842f.tar.xz
org.eclipse.jetty.project-2a765afdc63c12c3371c1defc73c88eaf948842f.zip
Improved javadocs and logging.
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java2
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java10
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/HeaderParser.java21
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ParamsContentParser.java35
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/Parser.java10
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ResponseContentParser.java10
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java4
7 files changed, 83 insertions, 9 deletions
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java
index 4be9cbf196..4d9691de50 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java
@@ -181,7 +181,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
if (channels.isEmpty())
close();
else
- failAndClose(new EOFException());
+ failAndClose(new EOFException(String.valueOf(getEndPoint())));
}
@Override
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java
index 2367fb65fb..912f4f8140 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java
@@ -22,6 +22,16 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.fcgi.FCGI;
+/**
+ * <p>Parser for the BEGIN_REQUEST frame body.</p>
+ * <pre>
+ * struct begin_request_body {
+ * ushort role;
+ * ubyte flags;
+ * ubyte[5] reserved;
+ * }
+ * </pre>
+ */
public class BeginRequestContentParser extends ContentParser
{
private final ServerParser.Listener listener;
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/HeaderParser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/HeaderParser.java
index 078105a9f3..7d43112569 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/HeaderParser.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/HeaderParser.java
@@ -21,9 +21,28 @@ package org.eclipse.jetty.fcgi.parser;
import java.nio.ByteBuffer;
import org.eclipse.jetty.fcgi.FCGI;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+/**
+ * <p>Parser for FastCGI frame headers.</p>
+ * <pre>
+ * struct frame_header {
+ * ubyte version;
+ * ubyte type;
+ * ushort requestId;
+ * ushort contentLength;
+ * ubyte paddingLength;
+ * ubyte reserved;
+ * }
+ * </pre>
+ *
+ * @see Parser
+ */
public class HeaderParser
{
+ private static final Logger LOG = Log.getLogger(Parser.class);
+
private State state = State.VERSION;
private int cursor;
private int version;
@@ -109,6 +128,8 @@ public class HeaderParser
case RESERVED:
{
buffer.get();
+ if (LOG.isDebugEnabled())
+ LOG.debug("Parsed request {} header {} length={}", getRequest(), getFrameType(), getContentLength());
return true;
}
default:
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ParamsContentParser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ParamsContentParser.java
index 4678ad5ebe..dcf34fefc8 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ParamsContentParser.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ParamsContentParser.java
@@ -20,11 +20,44 @@ package org.eclipse.jetty.fcgi.parser;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+/**
+ * <p>Parser for the PARAMS frame body.</p>
+ * <pre>
+ * struct small_name_small_value_params_body {
+ * ubyte nameLength;
+ * ubyte valueLength;
+ * ubyte[] nameBytes;
+ * ubyte[] valueBytes;
+ * }
+ *
+ * struct small_name_large_value_params_body {
+ * ubyte nameLength;
+ * uint valueLength;
+ * ubyte[] nameBytes;
+ * ubyte[] valueBytes;
+ * }
+ *
+ * struct large_name_small_value_params_body {
+ * uint nameLength;
+ * ubyte valueLength;
+ * ubyte[] nameBytes;
+ * ubyte[] valueBytes;
+ * }
+ *
+ * struct large_name_large_value_params_body {
+ * uint nameLength;
+ * uint valueLength;
+ * ubyte[] nameBytes;
+ * ubyte[] valueBytes;
+ * }
+ * </pre>
+ */
public class ParamsContentParser extends ContentParser
{
private static final Logger LOG = Log.getLogger(ParamsContentParser.class);
@@ -179,7 +212,7 @@ public class ParamsContentParser extends ContentParser
}
case PARAM:
{
- Charset utf8 = Charset.forName("UTF-8");
+ Charset utf8 = StandardCharsets.UTF_8;
onParam(new String(nameBytes, utf8), new String(valueBytes, utf8));
partialReset();
if (length == 0)
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/Parser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/Parser.java
index 402f3a4897..be2ac480c6 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/Parser.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/Parser.java
@@ -22,6 +22,8 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.http.HttpField;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
/**
* <p>The FastCGI protocol exchanges <em>frames</em>.</p>
@@ -39,9 +41,14 @@ import org.eclipse.jetty.http.HttpField;
* </pre>
* <p>Depending on the {@code type}, the content may have a different format,
* so there are specialized content parsers.</p>
+ *
+ * @see HeaderParser
+ * @see ContentParser
*/
public abstract class Parser
{
+ private static final Logger LOG = Log.getLogger(Parser.class);
+
protected final HeaderParser headerParser = new HeaderParser();
private State state = State.HEADER;
private int padding;
@@ -73,6 +80,9 @@ public abstract class Parser
else
{
ContentParser.Result result = contentParser.parse(buffer);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Parsed request {} content {} result={}", headerParser.getRequest(), headerParser.getFrameType(), result);
+
if (result == ContentParser.Result.PENDING)
{
// Not enough data, signal to read/parse more.
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ResponseContentParser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ResponseContentParser.java
index def4394cc1..6d0fefae64 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ResponseContentParser.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ResponseContentParser.java
@@ -35,8 +35,8 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
- * <p>The parser for STDOUT type frames.</p>
- * <p>STDOUT frames contain both the HTTP headers (but not the response line)
+ * <p>The parser for STDOUT type frame bodies.</p>
+ * <p>STDOUT frame bodies contain both the HTTP headers (but not the response line)
* and the HTTP content (either Content-Length delimited or chunked).</p>
* <p>For this reason, a special HTTP parser is used to parse the frames body.
* This special HTTP parser is configured to skip the response line, and to
@@ -99,12 +99,12 @@ public class ResponseContentParser extends StreamContentParser
public boolean parse(ByteBuffer buffer)
{
- if (LOG.isDebugEnabled())
- LOG.debug("Response {} {} content {} {}", request, FCGI.StreamType.STD_OUT, state, buffer);
-
int remaining = buffer.remaining();
while (remaining > 0)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("Response {} {}, state {} {}", request, FCGI.StreamType.STD_OUT, state, buffer);
+
switch (state)
{
case HEADERS:
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java
index ae7f7bc041..70602a626a 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java
@@ -25,8 +25,8 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
- * <p>A stream content parser parses frames of type STDIN, STDOUT and STDERR.</p>
- * <p>STDOUT frames are handled specially by {@link ResponseContentParser}.
+ * <p>A stream content parser parses frame bodies of type STDIN, STDOUT and STDERR.</p>
+ * <p>STDOUT frame bodies are handled specially by {@link ResponseContentParser}.
*/
public class StreamContentParser extends ContentParser
{

Back to the top