本文整理汇总了Java中javax.sip.header.ContentLengthHeader类的典型用法代码示例。如果您正苦于以下问题:Java ContentLengthHeader类的具体用法?Java ContentLengthHeader怎么用?Java ContentLengthHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentLengthHeader类属于javax.sip.header包,在下文中一共展示了ContentLengthHeader类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHeadersToOmmitOnResponseCopy
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
private static Set<String> getHeadersToOmmitOnResponseCopy() {
if (HEADERS_TO_OMMIT_ON_RESPONSE_COPY == null) {
final Set<String> set = new HashSet<String>();
set.add(RouteHeader.NAME);
set.add(RecordRouteHeader.NAME);
set.add(ViaHeader.NAME);
set.add(CallIdHeader.NAME);
set.add(CSeqHeader.NAME);
set.add(ContactHeader.NAME);
set.add(FromHeader.NAME);
set.add(ToHeader.NAME);
set.add(ContentLengthHeader.NAME);
HEADERS_TO_OMMIT_ON_RESPONSE_COPY = Collections.unmodifiableSet(set);
}
return HEADERS_TO_OMMIT_ON_RESPONSE_COPY;
}
示例2: processAck
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
void processAck(ServerTransaction serverTransaction, Request ackRequest) {
if (!serverTransaction.getDialog().getFirstTransaction()
.getRequest().getMethod().equals(Request.INVITE)) {
return;
}
// find the call
Call call = callDispatcher.findCall(serverTransaction.getDialog());
if (call == null) {
// this is most probably the ack for a killed call - don't
// signal it
// sipManCallback.fireUnknownMessageReceived(ackRequest);
return;
}
ContentLengthHeader cl = ackRequest.getContentLength();
if (cl != null && cl.getContentLength() > 0) {
call.setRemoteSdpDescription(new String(ackRequest
.getRawContent()));
}
// change status
call.setState(Call.CONNECTED);
}
示例3: setContentLength
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
/**
* Set the content length header.
*
* @param contentLength -- content length header.
*/
public void setContentLength(ContentLengthHeader contentLength) {
try {
this.contentLengthHeader.setContentLength(contentLength.getContentLength());
} catch (InvalidArgumentException ex) {
}
}
示例4: equals
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
public boolean equals(Object other) {
if (other instanceof ContentLengthHeader) {
final ContentLengthHeader o = (ContentLengthHeader) other;
return this.getContentLength() == o.getContentLength();
}
return false;
}
示例5: testAgainstRIMsgContent
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
private void testAgainstRIMsgContent( Message tiMsg, Message riMsg ) {
// Test equality using RI definition of equals
assertEquals( riMsg.getHeader( ContentLengthHeader.NAME ), tiMsg.getHeader( ContentLengthHeader.NAME ) );
assertEquals( riMsg.getHeader( ContentTypeHeader.NAME ), tiMsg.getHeader( ContentTypeHeader.NAME ) );
assertEquals( riMsg.getContent(), tiMsg.getContent() );
}
示例6: readMessageSipHeaderLines
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
private boolean readMessageSipHeaderLines(InputStream inputStream, boolean isPreviousLineCRLF) throws IOException {
boolean crlfReceived = false;
String line = readLine(inputStream); // This gives us a full line or if it didn't fit in the byte check it may give us part of the line
if(partialLineRead) {
partialLine = partialLine + line; // If we are reading partial line again we must concatenate it with the previous partial line to reconstruct the full line
} else {
line = partialLine + line; // If we reach the end of the line in this chunk we concatenate it with the partial line from the previous buffer to have a full line
partialLine = ""; // Reset the partial line so next time we will concatenate empty string instead of the obsolete partial line that we just took care of
if(!line.equals(CRLF)) { // CRLF indicates END of message headers by RFC
message.append(line); // Collect the line so far in the message buffer (line by line)
String lineIgnoreCase = line.toLowerCase();
// contribution from Alexander Saveliev compare to lower case as RFC 3261 states (7.3.1 Header Field Format) states that header fields are case-insensitive
if(lineIgnoreCase.startsWith(ContentLengthHeader.NAME.toLowerCase())) { // naive Content-Length header parsing to figure out how much bytes of message body must be read after the SIP headers
contentLength = Integer.parseInt(line.substring(
ContentLengthHeader.NAME.length()+1).trim());
} else if(lineIgnoreCase.startsWith(CallIdHeader.NAME.toLowerCase())) { // naive Content-Length header parsing to figure out how much bytes of message body must be read after the SIP headers
callId = line.substring(
CallIdHeader.NAME.length()+1).trim();
}
} else {
if(isPreviousLineCRLF) {
// Handling keepalive ping (double CRLF) as defined per RFC 5626 Section 4.4.1
// sending pong (single CRLF)
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("KeepAlive Double CRLF received, sending single CRLF as defined per RFC 5626 Section 4.4.1");
logger.logDebug("~~~ setting isPreviousLineCRLF=false");
}
crlfReceived = false;
try {
sipMessageListener.sendSingleCLRF();
} catch (Exception e) {
logger.logError("A problem occured while trying to send a single CLRF in response to a double CLRF", e);
}
} else {
crlfReceived = true;
if (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
logger.logDebug("Received CRLF");
}
if(sipMessageListener != null &&
sipMessageListener instanceof ConnectionOrientedMessageChannel) {
((ConnectionOrientedMessageChannel)sipMessageListener).cancelPingKeepAliveTimeoutTaskIfStarted();
}
}
if(message.length() > 0) { // if we havent read any headers yet we are between messages and ignore CRLFs
readingMessageBodyContents = true;
readingHeaderLines = false;
partialLineRead = false;
message.append(CRLF); // the parser needs CRLF at the end, otherwise fails TODO: Is that a bug?
if(logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("Content Length parsed is " + contentLength);
}
contentReadSoFar = 0;
messageBody = new byte[contentLength];
}
}
}
return crlfReceived;
}
示例7: getContentLengthHeader
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
/**
* Get the contentLength header.
*/
public ContentLengthHeader getContentLengthHeader() {
return this.getContentLength();
}
示例8: getContentLengthHeader
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
/**
* Get the content length header or null if none present.
*
* @since v2.0
*/
public ContentLengthHeader getContentLengthHeader();
示例9: getContentLength
import javax.sip.header.ContentLengthHeader; //导入依赖的package包/类
/**
* Get the ContentLength header (null if one does not exist).
*
* @return content-length header.
*/
public ContentLengthHeader getContentLength() {
return this.contentLengthHeader;
}