{
onBadMessage(400, "Missing required request line elements");
return false;
}
HttpMethod httpMethod = HttpMethod.fromString(methodHeader.getValue());
HttpVersion httpVersion = HttpVersion.fromString(versionHeader.getValue());
if (LOG.isDebugEnabled())
LOG.debug("HTTP > {} {} {}", httpMethod, uriHeader.getValue(), httpVersion);
HostPortHttpField hostPort = null;
HttpFields fields = new HttpFields();
for (Fields.Field header : headers)
{
String name = header.getName();
// Skip special SPDY headers, unless it's the "host" header
HTTPSPDYHeader specialHeader = HTTPSPDYHeader.from(stream.getSession().getVersion(), name);
if (specialHeader != null)
{
if (specialHeader != HTTPSPDYHeader.HOST)
continue;
name = "host";
}
switch (name)
{
case "connection":
case "keep-alive":
case "proxy-connection":
case "transfer-encoding":
{
// Spec says to ignore these headers.
break;
}
case "host":
{
hostPort = new HostPortHttpField(header.getValue());
break;
}
default:
{
// Spec says headers must be single valued
String value = header.getValue();
if (LOG.isDebugEnabled())
LOG.debug("HTTP > {}: {}", name, value);
fields.add(new HttpField(name, value));
break;
}
}
}
if (hostPort == null)
{
onBadMessage(400, "Missing Host header");
return false;
}
// At last, add the Host header.
if (hostPort!=null)
fields.add(hostPort);
Fields.Field schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version));
HttpURI uri = new HttpURI(uriHeader.getValue());
if (uri.getScheme()==null && schemeHeader!=null)
uri.setScheme(schemeHeader.getValue());
if (uri.getHost()==null && hostPort!=null)
uri.setAuthority(hostPort.getHost(),hostPort.getPort());
MetaData.Request request = new MetaData.Request(httpMethod==null?methodHeader.getValue():httpMethod.asString(), uri, httpVersion, fields);
onRequest(request);
return true;
}