void HttpParsingBasicObject::extractServerVersionNum() { StrCSumPtrLen serverKey = "Server"; StrPtrLen serverValue; if (!iParser->getField(serverKey, serverValue)) return; if (serverValue.length() == 0) return; // Has Sever header char *ptr = (char*)serverValue.c_str(); for (int32 i = 0; i < serverValue.length(); i++) { if (!PE_isDigit(*ptr)) { ptr++; continue; } iServerVersionNumber = *ptr++ - '0'; if (PE_isDigit(*ptr) && ++i < serverValue.length()) { iServerVersionNumber = iServerVersionNumber * 10 + (*ptr - '0'); } break; } }
OSCL_EXPORT_REF bool RTSPOutgoingMessage::compose() { // compose the first line // switch (msgType) { case RTSPResponseMsg: { // RTSP version // oscl_memcpy(fullRequestBuffer, RTSPVersionString, RTSPVersionString_len); fullRequestBufferSpace += RTSPVersionString_len; *(fullRequestBufferSpace++) = ' '; // Status code // oscl_snprintf(fullRequestBufferSpace, RTSP_MAX_FULL_REQUEST_SIZE - 1, "%d", statusCode); // resync the pointer and size used fullRequestBufferSizeUsed = oscl_strlen(fullRequestBufferSpace); fullRequestBufferSpace += fullRequestBufferSizeUsed; *(fullRequestBufferSpace++) = ' '; fullRequestBufferSizeUsed += 1 + RTSPVersionString_len + 1; if (0 != reasonString.length()) { // user specified his own string // oscl_memcpy(fullRequestBufferSpace, reasonString.c_str(), reasonString.length()); fullRequestBufferSpace += reasonString.length(); fullRequestBufferSizeUsed += reasonString.length(); } else { StrPtrLen realReasonString ; // user wants the built-in default // switch (statusCode) { case CodeContinue: realReasonString = RtspReasonStringContinue; break; case CodeOK: realReasonString = RtspReasonStringOK; break; case CodeCreated: realReasonString = RtspReasonStringCreated; break; case CodeLowOnStorageSpace: realReasonString = RtspReasonStringLowOnStorageSpace; break; case CodeMultipleChoices: realReasonString = RtspReasonStringMultipleChoices; break; case CodeMovedPermanently: realReasonString = RtspReasonStringMovedPermanently; break; case CodeMovedTemporarily: realReasonString = RtspReasonStringMovedTemporarily; break; case CodeSeeOther: realReasonString = RtspReasonStringSeeOther; break; case CodeNotModified: realReasonString = RtspReasonStringNotModified; break; case CodeUseProxy: realReasonString = RtspReasonStringUseProxy; break; case CodeBadRequest: realReasonString = RtspReasonStringBadRequest; break; case CodeUnauthorized: realReasonString = RtspReasonStringUnauthorized; break; case CodePaymentRequired: realReasonString = RtspReasonStringPaymentRequired; break; case CodeForbidden: realReasonString = RtspReasonStringForbidden; break; case CodeNotFound: realReasonString = RtspReasonStringNotFound; break; case CodeMethodNotAllowed: realReasonString = RtspReasonStringMethodNotAllowed; break; case CodeNotAcceptable: realReasonString = RtspReasonStringNotAcceptable; break; case CodeProxyAuthenticationRequired: realReasonString = RtspReasonStringProxyAuthenticationRequired; break; case CodeRequestTimeOut: realReasonString = RtspReasonStringRequestTimeOut; break; case CodeGone: realReasonString = RtspReasonStringGone; break; case CodeLengthRequired: realReasonString = RtspReasonStringLengthRequired; break; case CodePreconditionFailed: realReasonString = RtspReasonStringPreconditionFailed; break; case CodeRequestEntityTooLarge: realReasonString = RtspReasonStringRequestEntityTooLarge; break; case CodeRequestURITooLarge: realReasonString = RtspReasonStringRequestURITooLarge; break; case CodeUnsupportedMediaType: realReasonString = RtspReasonStringUnsupportedMediaType; break; case CodeSessionNotFound: realReasonString = RtspReasonStringSessionNotFound; break; case CodeMethodNotValidInThisState: realReasonString = RtspReasonStringMethodNotValidInThisState; break; case CodeHeaderFieldNotValidForResource: realReasonString = RtspReasonStringHeaderFieldNotValidForResource; break; case CodeInvalidRange: realReasonString = RtspReasonStringInvalidRange; break; case CodeParameterIsReadOnly: realReasonString = RtspReasonStringParameterIsReadOnly; break; case CodeAggregateOperationNotAllowed: realReasonString = RtspReasonStringAggregateOperationNotAllowed; break; case CodeOnlyAggregateOperationAllowed: realReasonString = RtspReasonStringOnlyAggregateOperationAllowed; break; case CodeUnsupportedTransport: realReasonString = RtspReasonStringUnsupportedTransport; break; case CodeDestinationUnreachable: realReasonString = RtspReasonStringDestinationUnreachable; break; case CodeUnsupportedClient: realReasonString = RtspReasonStringUnsupportedClient; break; case CodeInternalServerError: realReasonString = RtspReasonStringInternalServerError; break; case CodeNotImplemented: realReasonString = RtspReasonStringNotImplemented; break; case CodeBadGateway: realReasonString = RtspReasonStringBadGateway; break; case CodeServiceUnavailable: realReasonString = RtspReasonStringServiceUnavailable; break; case CodeGatewayTimeout: realReasonString = RtspReasonStringGatewayTimeout; break; case CodeRTSPVersionNotSupported: realReasonString = RtspReasonStringRTSPVersionNotSupported; break; case CodeOptionNotSupported: realReasonString = RtspReasonStringOptionNotSupported; break; case CodeParameterNotUnderstood: realReasonString = RtspReasonStringParameterNotUnderstood; break; default: // no string was found, since code is unknown... ;;; } if (realReasonString.length()) { oscl_memcpy(fullRequestBufferSpace, realReasonString.c_str(), realReasonString.length()); fullRequestBufferSpace += realReasonString.length(); fullRequestBufferSizeUsed += realReasonString.length(); } } break; } case RTSPRequestMsg: { if (METHOD_BINARY_DATA == method) { // it's interleaved stuff // leading dollar *(fullRequestBufferSpace++) = CHAR_DOLLAR; // 8-bit channel-id from the content-type *(fullRequestBufferSpace++) = contentType.c_str()[0]; // 16-bit content length, in network byte order *(fullRequestBufferSpace++) = char((contentLength & 0xFF00) >> 8); *(fullRequestBufferSpace++) = char((contentLength & 0xFF)); *fullRequestBufferSpace = CHAR_NULL; fullRequestBufferSizeUsed = 4; fullRequestPLS = fullRequestBuffer; return true; } // okay, it's a normal request // do the method if (method < 0 || method >= METHOD_NUM_ENTRIES) { // method unknown return false; } uint32 method_strlen = oscl_strlen(RtspMethodStringPLSS[method]); oscl_memcpy(fullRequestBufferSpace, RtspMethodStringPLSS[method], method_strlen ); fullRequestBufferSpace += method_strlen; *(fullRequestBufferSpace++) = CHAR_SPACE; fullRequestBufferSizeUsed += method_strlen + 1; // do the URI oscl_memcpy(fullRequestBufferSpace, originalURI.c_str(), originalURI.length() ); fullRequestBufferSpace += originalURI.length(); *(fullRequestBufferSpace++) = CHAR_SPACE; fullRequestBufferSizeUsed += originalURI.length() + 1; // do the RTSP version #ifdef SIMPLE_HTTP_SUPPORT if ((method == METHOD_GET) || (method == METHOD_POST)) { oscl_memcpy(fullRequestBufferSpace, HTTPVersion_1_0_String, HTTPVersionString_len ); } else #endif oscl_memcpy(fullRequestBufferSpace, RTSPVersionString, RTSPVersionString_len ); fullRequestBufferSpace += RTSPVersionString_len; fullRequestBufferSizeUsed += RTSPVersionString_len; break; } default: { // cannot encode an unknown type of message return false; } }