/**
   * Constructor.
   *
   * @param context The context of the parent connector.
   * @param connection The associated network connection.
   * @param methodName The protocol method name.
   * @param resourceUri The target resource URI.
   * @param protocol The protocol name and version.
   */
  public SipInboundRequest(
      Context context,
      Connection<Server> connection,
      String methodName,
      String resourceUri,
      String protocol) {
    super();
    this.context = context;
    this.cacheDirectivesAdded = false;
    this.clientAdded = false;
    this.conditionAdded = false;
    this.connection = connection;
    this.cookiesAdded = false;
    this.referrerAdded = false;
    this.securityAdded = false;
    this.userPrincipal = null;
    this.proxySecurityAdded = false;
    this.recipientsInfoAdded = false;
    this.resourceUri = resourceUri;
    this.protocol = protocol;
    this.warningsAdded = false;

    // SIP specific initialization
    this.alertInfoAdded = false;
    this.allowedEventTypesAdded = false;
    this.callerInfoAdded = false;
    this.contactAdded = false;
    this.eventAdded = false;
    this.inReplyToAdded = false;
    this.priorityAdded = false;

    // Set the properties
    setMethod(Method.valueOf(methodName));
  }
  /**
   * Returns the target method according to a list of properties.
   *
   * @param resolver The resolver.
   * @return The target method.
   */
  protected Method getTargetMethod(Resolver<String> resolver) {
    Method method = Method.valueOf(resolver.resolve("method"));
    if (method == null) {
      method = getTargetMethod();
    }

    return method;
  }
  /**
   * Constructor.
   *
   * @param context The context of the HTTP server connector that issued the call.
   * @param httpCall The low-level HTTP server call.
   */
  public HttpRequest(Context context, ServerCall httpCall) {
    this.context = context;
    this.clientAdded = false;
    this.conditionAdded = false;
    this.cookiesAdded = false;
    this.entityAdded = false;
    this.referrerAdded = false;
    this.securityAdded = false;
    this.proxySecurityAdded = false;
    this.recipientsInfoAdded = false;
    this.warningsAdded = false;
    this.httpCall = httpCall;

    // Set the properties
    setMethod(Method.valueOf(httpCall.getMethod()));

    // Set the host reference
    StringBuilder sb = new StringBuilder();
    sb.append(httpCall.getProtocol().getSchemeName()).append("://");
    sb.append(httpCall.getHostDomain());
    if ((httpCall.getHostPort() != -1)
        && (httpCall.getHostPort() != httpCall.getProtocol().getDefaultPort())) {
      sb.append(':').append(httpCall.getHostPort());
    }
    setHostRef(sb.toString());

    // Set the resource reference
    if (httpCall.getRequestUri() != null) {
      setResourceRef(new Reference(getHostRef(), httpCall.getRequestUri()));

      if (getResourceRef().isRelative()) {
        // Take care of the "/" between the host part and the segments.
        if (!httpCall.getRequestUri().startsWith("/")) {
          setResourceRef(new Reference(getHostRef().toString() + "/" + httpCall.getRequestUri()));
        } else {
          setResourceRef(new Reference(getHostRef().toString() + httpCall.getRequestUri()));
        }
      }

      setOriginalRef(getResourceRef().getTargetRef());
    }

    // Set the request date
    String dateHeader = httpCall.getRequestHeaders().getFirstValue(HeaderConstants.HEADER_DATE);
    Date date = null;
    if (dateHeader != null) {
      date = DateUtils.parse(dateHeader);
    }

    if (date == null) {
      date = new Date();
    }

    setDate(date);
  }