コード例 #1
0
 /**
  * Get the message as a linked list of strings. Use this if you want to iterate through the
  * message.
  *
  * @return a linked list containing the request line and headers encoded as strings.
  */
 public LinkedList getMessageAsEncodedStrings() {
   LinkedList retval = super.getMessageAsEncodedStrings();
   if (requestLine != null) {
     this.setRequestLineDefaults();
     retval.addFirst(requestLine.encode());
   }
   return retval;
 }
コード例 #2
0
 /** Encode only the headers and not the content. */
 public String encodeMessage() {
   String retval;
   if (requestLine != null) {
     this.setRequestLineDefaults();
     retval = requestLine.encode() + super.encodeSIPHeaders();
   } else if (this.isNullRequest()) {
     retval = "\r\n\r\n";
   } else retval = super.encodeSIPHeaders();
   return retval;
 }
コード例 #3
0
  /**
   * Encode this into a byte array. This is used when the body has been set as a binary array and
   * you want to encode the body as a byte array for transmission.
   *
   * @return a byte array containing the SIPRequest encoded as a byte array.
   */
  public byte[] encodeAsBytes(String transport) {
    if (this.isNullRequest()) {
      // Encoding a null message for keepalive.
      return "\r\n\r\n".getBytes();
    } else if (this.requestLine == null) {
      return new byte[0];
    }

    byte[] rlbytes = null;
    if (requestLine != null) {
      try {
        rlbytes = requestLine.encode().getBytes("UTF-8");
      } catch (UnsupportedEncodingException ex) {
        InternalErrorHandler.handleException(ex);
      }
    }
    byte[] superbytes = super.encodeAsBytes(transport);
    byte[] retval = new byte[rlbytes.length + superbytes.length];
    System.arraycopy(rlbytes, 0, retval, 0, rlbytes.length);
    System.arraycopy(superbytes, 0, retval, rlbytes.length, superbytes.length);
    return retval;
  }