Uploaded image for project: 'Identity Gateway'
  1. Identity Gateway
  2. OPENIG-8

OpenIG gateway removes Content-Length: 0

    XMLWordPrintable

    Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.0
    • 3.0.0
    • None
    • OpenIG 2.0.0-Snapshot (December 19, 2011)

      Description

      I've found this issue when running WEBDAV traffic through the Gateway. I found that the PROPFIND method is sending a Content-Length: 0 and the gateway strips this off (see attachment for before and after captures).

      According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13 "Any Content-Length greater than or equal to zero is a valid value."

      In ClientHandler.java method handle(Exchange exchange), Content-Length is suppressed if the exchange.request.entity is null.

      This is pretty obscure so I choose not to call this a bug... I thought it worth submitting though as information at a minimum.

      My hack fix for this (only addressing my immediate problem) is:

      public void handle(Exchange exchange) throws HandlerException, IOException {
      LogTimer timer = logger.getTimer().start();
      // recover any previous response connection, if present
      if (exchange.response != null && exchange.response.entity != null)

      { exchange.response.entity.close(); }

      HttpRequestBase clientRequest = (exchange.request.entity != null ?
      new EntityRequest(exchange.request) : new NonEntityRequest(exchange.request));
      clientRequest.setURI(exchange.request.uri);
      // connection headers to suppress
      CaseInsensitiveSet suppressConnection = new CaseInsensitiveSet();
      // parse request connection headers to be suppressed in request
      suppressConnection.clear();
      suppressConnection.addAll(new ConnectionHeader(exchange.request).tokens);
      // request headers
      for (String name : exchange.request.headers.keySet()) {
      if (!SUPPRESS_REQUEST_HEADERS.contains(name) && !suppressConnection.contains(name)) {
      for (String value : exchange.request.headers.get(name))

      { clientRequest.addHeader(name, value); }

      }
      }
      + if (exchange.request.entity == null && "PROPFIND".equals(exchange.request.method))

      { + clientRequest.addHeader(ContentLengthHeader.NAME, "0"); + }

      // send request
      HttpResponse clientResponse = httpClient.execute(clientRequest);
      exchange.response = new Response();

        Attachments

          Activity

            People

            markdr Mark de Reeper
            crisallt crisallt
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: