public static void writeHttpRequest(OutputStream stream, Keyword method, String host, String urlPath, KeyValueList headers, Stella_Object content) {
    { long contentlength = 0l;

      stream.nativeStream.print(method.symbolName + " " + urlPath + " HTTP/1.0\r\n");
      if (host != null) {
        if (headers == null) {
          headers = KeyValueList.newKeyValueList();
        }
        headers.insertAt(StringWrapper.wrapString("Host"), StringWrapper.wrapString(host));
      }
      if (content != null) {
        { Object [] caller_MV_returnarray = new Object[1];

          content = Http.getContentAndLength(content, caller_MV_returnarray);
          contentlength = ((long)(((LongIntegerWrapper)(caller_MV_returnarray[0])).wrapperValue));
        }
        if (headers == null) {
          headers = KeyValueList.newKeyValueList();
        }
        headers.insertAt(StringWrapper.wrapString("Content-Length"), StringWrapper.wrapString(Native.integerToString(contentlength)));
      }
      if (headers != null) {
        { StringWrapper key = null;
          StringWrapper value = null;
          KvCons iter000 = headers.theKvList;

          for (;iter000 != null; iter000 = iter000.rest) {
            key = ((StringWrapper)(iter000.key));
            value = ((StringWrapper)(iter000.value));
            stream.nativeStream.print(StringWrapper.unwrapString(key) + ": " + StringWrapper.unwrapString(value) + "\r\n");
          }
        }
      }
      stream.nativeStream.print("Connection: close\r\n");
      stream.nativeStream.print("\r\n");
      if (content != null) {
        { Surrogate testValue000 = Stella_Object.safePrimaryType(content);

          if (Surrogate.subtypeOfStringP(testValue000)) {
            { StringWrapper content000 = ((StringWrapper)(content));

              stream.nativeStream.print(StringWrapper.unwrapString(content000));
            }
          }
          else if (Surrogate.subtypeOfP(testValue000, Http.SGT_STELLA_INPUT_STREAM)) {
            { InputStream content000 = ((InputStream)(content));

              InputStream.copyStreamToStream(content000, stream);
            }
          }
          else {
            { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
              throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
            }
          }
        }
      }
      OutputStream.flushOutput(stream);
    }
  }