Ejemplo n.º 1
0
void HttpRequestContext::extractPostCgiVariables(const HttpBody& body)
{
    int length;
    UtlString bodyBytes;

    body.getBytes(&bodyBytes, &length);
    parseCgiVariables(bodyBytes.data());
    bodyBytes.remove(0);
}
Ejemplo n.º 2
0
// Dump the object's internal state.
void PublishContentContainer::dumpState()
{
   // indented 8 and 10

   UtlString key(*this);
   key.replace(sizeof (CONTENT_KEY_SEPARATOR) - 1,
               key.index(CONTENT_KEY_SEPARATOR),
               " ");
   Os::Logger::instance().log(FAC_RLS, PRI_INFO,
                 "\t        PublishContentContainer %p UtlString = '%s'",
                 this, data());

   int index = 0;
   UtlSListIterator content_itor(mEventContent);
   HttpBody* body;
   while ((body = dynamic_cast <HttpBody*> (content_itor())))
   {
      Os::Logger::instance().log(FAC_RLS, PRI_INFO,
                    "\t          mEventContent[%d] = '%s':'%s'",
                    index, body->data(), body->getBytes());
      index++;
   }
}
Ejemplo n.º 3
0
// Dump the object's internal state.
void PublishContentContainer::dumpState()
{
    // indented 8 and 10

    OsSysLog::add(FAC_RLS, PRI_INFO,
                  "\t        PublishContentContainer %p UtlString = '%s'",
                  this, data());

    int index = 0;
    UtlSListIterator content_itor(mEventContent);
    UtlSListIterator version_itor(mEventVersion);
    HttpBody* body;
    while ((body = dynamic_cast <HttpBody*> (content_itor())))
    {
        UtlInt* version = dynamic_cast <UtlInt*> (version_itor());
        OsSysLog::add(FAC_RLS, PRI_INFO,
                      "\t          mEventVersion[%d] = %" PRIdPTR ", "
                      "mEventContent[%d] = '%s':'%s'",
                      index, version->getValue(),
                      index, body->data(), body->getBytes());
        index++;
    }
}
Ejemplo n.º 4
0
// Append a multipart body part to an existing multiparty body.
void HttpBody::appendBodyPart(const HttpBody& body,
                              const UtlDList& parameters)
{
   assert(isMultipart());

   // Construct a new MimeBodyPart for the new body part.
   MimeBodyPart* part = new MimeBodyPart(body, parameters);

   // Insert it as the last body part.
   mBodyParts.append(part);
   mBodyPartCount++;

   // Turn the final boundary into an intermediate boundary.
   mBody.remove(mBody.length() - 4);
   mBody.append("\r\n");

   // Insert the headers.
   ssize_t rawPartStart = mBody.length();
   UtlDListIterator iterator(*part->getParameters());
   NameValuePair* nvp;
   while ((nvp = (NameValuePair*) iterator()))
   {
      mBody.append(nvp->data());
      mBody.append(": ");
      mBody.append(nvp->getValue());
      mBody.append("\r\n");
   }
   mBody.append("\r\n");

   // Insert the body.
   ssize_t partStart = mBody.length();
   const char* bytes;
   ssize_t length;
   body.getBytes(&bytes, &length);
   mBody.append(bytes, length);
   ssize_t partEnd = mBody.length();

   // Update bodyLength.
   bodyLength = mBody.length();

   // Determine if we have to change the boundary string.
   bool change_boundary_string =
      mBody.index(mMultipartBoundary, partStart) != UTL_NOT_FOUND;

   // Add the final boundary.
   mBody.append("\r\n--");
   mBody.append(mMultipartBoundary);
   mBody.append("--\r\n");

   // Update the MimeBodyPart to know where it is contained in the HttpBody.
   part->attach(this,
                rawPartStart, partEnd - rawPartStart,
                partStart, partEnd - partStart);

   // If we have to change the boundary string.
   if (change_boundary_string)
   {
      // Find a new boundary string that isn't in the body.
      do {
         nextBoundary(mMultipartBoundary);
      } while (mBody.index(mMultipartBoundary) != UTL_NOT_FOUND);

      // Replace the old boundary string.
      UtlSListIterator iterator(mBodyParts);
      MimeBodyPart* part;
      while ((part = dynamic_cast<MimeBodyPart*>(iterator())))
      {
            // Replace the boundary string just before this part.
            mBody.replace(part->getRawStart() - (2 + BOUNDARY_STRING_LENGTH),
                          BOUNDARY_STRING_LENGTH,
                          mMultipartBoundary.data(),
                          BOUNDARY_STRING_LENGTH);
      }

      // Replace the boundary string in the final boundary.
      mBody.replace(mBody.length() - (4 + BOUNDARY_STRING_LENGTH),
                    BOUNDARY_STRING_LENGTH,
                    mMultipartBoundary.data(),
                    BOUNDARY_STRING_LENGTH);

      // Replace the boundary string in the Content-Type.
      ssize_t loc = this->index(";" MULTIPART_BOUNDARY_PARAMETER "=\"");
      this->replace(loc + sizeof (";" MULTIPART_BOUNDARY_PARAMETER "=\"") - 1,
                    BOUNDARY_STRING_LENGTH,
                    mMultipartBoundary.data(),
                    BOUNDARY_STRING_LENGTH);
   }
}