Exemple #1
0
MHSyncItemInfo::MHSyncItemInfo(MHSyncItemInfo& copy) {
    iD = copy.getId();
    setGuid(copy.getGuid());
    setLuid(copy.getLuid());
    setName(copy.getName());
    setSize(copy.getSize());
    setServerUrl(copy.getServerUrl());
    setContentType(copy.getContentType());
    setCreationDate(copy.getCreationDate());
    setModificationDate(copy.getModificationDate());
    setStatus(copy.getStatus());
    setServerLastUpdate(copy.getServerLastUpdate());
    setRemoteItemUrl(copy.getRemoteItemUrl());
    setRemoteThumbUrl(copy.getRemoteThumbUrl());
    setRemotePreviewUrl(copy.getRemotePreviewUrl());
    setLocalThumbPath(copy.getLocalThumbPath());
    setLocalPreviewPath(copy.getLocalPreviewPath());
    setLocalItemPath(copy.getLocalItemPath());
    
    setLocalItemETag(copy.getLocalItemETag().c_str());
    setLocalThumbETag(copy.getLocalThumbETag().c_str());
    setLocalPreviewETag(copy.getLocalPreviewETag().c_str());

    setRemoteItemETag(copy.getRemoteItemETag().c_str());
    setRemoteThumbETag(copy.getRemoteThumbETag().c_str());
    setRemotePreviewETag(copy.getRemotePreviewETag().c_str());
    
    setItemExifData(copy.exifData);
    setItemVideoMetadata(copy.videoMetadata);
    setExportedServices(copy.exportedServices);
    setShared(copy.shared);
    setNumUploadFailures(copy.numUploadFailures);
}
    //-----------------------------------------------------------------------
    void TextureUnitState::setAnimatedTextureName(const String* const names, unsigned int numFrames, Real duration)
    {
		setContentType(CONTENT_NAMED);
		mTextureLoadFailed = false;

		mFrames.resize(numFrames);
		// resize pointers, but don't populate until needed
        mFramePtrs.resize(numFrames);
        mAnimDuration = duration;
        mCurrentFrame = 0;
        mCubic = false;

        for (unsigned int i = 0; i < mFrames.size(); ++i)
        {
            mFrames[i] = names[i];
			mFramePtrs[i].setNull();
        }

        // Load immediately if Material loaded
        if (isLoaded())
        {
            _load();
        }
		// Tell parent to recalculate hash
		if( Pass::getHashFunction() == Pass::getBuiltinHashFunction( Pass::MIN_TEXTURE_CHANGE ) )
		{
			mParent->_dirtyHash();
		}
    }
Exemple #3
0
MailMessage::MailMessage(PartStoreFactory* pStoreFactory): 
	_pStoreFactory(pStoreFactory)
{
	Poco::Timestamp now;
	setDate(now);
	setContentType("text/plain");
}
bool HttpResponse::sendFile(String fileName, bool allowGzipFileCheck /* = true*/)
{
	if (stream != NULL)
	{
		SYSTEM_ERROR("Stream already created");
		delete stream;
		stream = NULL;
	}

	String compressed = fileName + ".gz";
	if (allowGzipFileCheck && fileExist(compressed))
	{
		debugf("found %s", compressed.c_str());
		stream = new FileStream(compressed);
		setHeader("Content-Encoding", "gzip");
	}
	else if (fileExist(fileName))
	{
		debugf("found %s", fileName.c_str());
		stream = new FileStream(fileName);
	}
	else
	{
		notFound();
		return false;
	}

	if (!hasHeader("Content-Type"))
	{
		const char *mime = ContentType::fromFullFileName(fileName);
		if (mime != NULL)
			setContentType(mime);
	}
	return true;
}
void QMessageContentContainerPrivate::setContent(const QByteArray &content, const QByteArray &type, const QByteArray &subType, const QByteArray &charset)
{
    setContentType(type, subType, charset);

    _content = content;
    _available = true;
}
Exemple #6
0
IMM::IMM(BOOM::Vector<TrainingSequence*> &v,int order,
	 int minSampleSize,int phase,ContentType contentType,
	 Strand strand)
  : N(order),
    alphabetSize(alphabet.getNumElements()),
    phase(phase),
    revComp(NULL),
    models(new BOOM::Vector<BOOM::StringMap<double>*>)
{
  setContentType(contentType);
  if(strand==EITHER_STRAND) strand=::getStrand(contentType);
  setStrand(strand);

  buildModels(v,minSampleSize);

  if(strand==FORWARD_STRAND)
    {
      BOOM::Vector<TrainingSequence*> rcSeqs;
      revCompSeqs(v,rcSeqs);
      revComp=new IMM(rcSeqs,order,minSampleSize,phase,
		      ::reverseComplement(contentType),
		      REVERSE_STRAND);
      revComp->revComp=this;
    }
}
void HTTPServerResponseImpl::sendFile(const std::string& path, const std::string& mediaType)
{
	poco_assert (!_pStream);

	File f(path);
	Timestamp dateTime    = f.getLastModified();
	File::FileSize length = f.getSize();
	set("Last-Modified", DateTimeFormatter::format(dateTime, DateTimeFormat::HTTP_FORMAT));
#if defined(POCO_HAVE_INT64)
	setContentLength64(length);
#else
	setContentLength(static_cast<int>(length));
#endif
	setContentType(mediaType);
	setChunkedTransferEncoding(false);

	Poco::FileInputStream istr(path);
	if (istr.good())
	{
		_pStream = new HTTPHeaderOutputStream(_session);
		write(*_pStream);
		if (_pRequest && _pRequest->getMethod() != HTTPRequest::HTTP_HEAD)
		{
			StreamCopier::copyStream(istr, *_pStream);
		}
	}
	else throw OpenFileException(path);
}
bool HttpResponse::sendTemplate(TemplateFileStream* newTemplateInstance)
{
	if (stream != NULL)
	{
		SYSTEM_ERROR("Stream already created");
		delete stream;
		stream = NULL;
	}

	stream = newTemplateInstance;
	if (!newTemplateInstance->fileExist())
	{
		notFound();
		delete stream;
		stream = NULL;
		return false;
	}

	if (!hasHeader("Content-Type"))
	{
		const char *mime = ContentType::fromFullFileName(newTemplateInstance->fileName());
		if (mime != NULL)
			setContentType(mime);
	}
	return true;
}
Exemple #9
0
  ////////////////////////////////////////////////////////////////////////
  // componentdefinition
  //
  unsigned Unzip::operator() (tnt::HttpRequest& request, tnt::HttpReply& reply, tnt::QueryParams& qparams)
  {
    std::string pi = request.getPathInfo();

    log_debug("unzip archive \"" << request.getArg("file") << "\" file \"" << pi << '"');

    try
    {
      unzipFile f(request.getArg("file"));
      unzipFileStream in(f, pi, false);

      // set Content-Type
      std::string contentType = request.getArg("contenttype");
      if (contentType.empty())
        setContentType(request, reply);
      else
        reply.setContentType(contentType);

      reply.out() << in.rdbuf();
    }
    catch (const unzipEndOfListOfFile&)
    {
      log_debug("file \"" << pi << "\" not found in archive");
      return DECLINED;
    }

    return HTTP_OK;
  }
Exemple #10
0
void IMM::load(istream &is)
{
  int numModels, numElements;
  BOOM::String str, pStr;
  ContentType contentType;
  
  is >> contentType >> N >> phase >> numModels;
  setContentType(contentType);

  for(int i=0 ; i<numModels ; ++i)
    {
      models->push_back(new BOOM::StringMap<double>(hashTableSize(N)));
      BOOM::StringMap<double> &model=*(*models)[i];
      is >> numElements;
      for(int j=0 ; j<numElements ; ++j)
	{
	  is >> str >> pStr;
	  model.lookup(str.c_str(),str.length())=pStr.asDouble();
	}
    }

  if(getStrand()==FORWARD_STRAND)
    {
      BOOM::String modelType;
      is >> modelType;
      revComp=new IMM(is,REVERSE_STRAND);
      revComp->revComp=this;
    }
Exemple #11
0
void QxtMailAttachment::setExtraHeader(const QString& key, const QString& value)
{
    if (key.compare(QStringLiteral("Content-Type"), Qt::CaseInsensitive) == 0)
        setContentType(value);
    else
        qxt_d->extraHeaders[key.toLower()] = value;
}
Exemple #12
0
Blob* XMLHttpRequest::responseBlob()
{
    ASSERT(m_responseTypeCode == ResponseTypeBlob);
    ASSERT(doneWithoutErrors());

    if (!m_responseBlob) {
        // FIXME: This causes two (or more) unnecessary copies of the data.
        // Chromium stores blob data in the browser process, so we're pulling the data
        // from the network only to copy it into the renderer to copy it back to the browser.
        // Ideally we'd get the blob/file-handle from the ResourceResponse directly
        // instead of copying the bytes. Embedders who store blob data in the
        // same process as WebCore would at least to teach BlobData to take
        // a SharedBuffer, even if they don't get the Blob from the network layer directly.
        auto blobData = std::make_unique<BlobData>();
        // If we errored out or got no data, we still return a blob, just an empty one.
        size_t size = 0;
        if (m_binaryResponseBuilder) {
            RefPtr<RawData> rawData = RawData::create();
            size = m_binaryResponseBuilder->size();
            rawData->mutableData()->append(m_binaryResponseBuilder->data(), size);
            blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile);
            String normalizedContentType = Blob::normalizedContentType(responseMIMEType());
            blobData->setContentType(normalizedContentType); // responseMIMEType defaults to text/xml which may be incorrect.
            m_binaryResponseBuilder.clear();
        }
        m_responseBlob = Blob::create(std::move(blobData), size);
    }

    return m_responseBlob.get();
}
    //-----------------------------------------------------------------------
    void TextureUnitState::setCubicTextureName( const String& name, bool forUVW)
    {
        if (forUVW)
        {
            setCubicTextureName(&name, forUVW);
        }
        else
        {
			setContentType(CONTENT_NAMED);
			mTextureLoadFailed = false;
            String ext;
            String suffixes[6] = {"_fr", "_bk", "_lf", "_rt", "_up", "_dn"};
            String baseName;
            String fullNames[6];

            size_t pos = name.find_last_of(".");
			if( pos != String::npos )
			{
				baseName = name.substr(0, pos);
				ext = name.substr(pos);
			}
			else
				baseName = name;

            for (int i = 0; i < 6; ++i)
            {
                fullNames[i] = baseName + suffixes[i] + ext;
            }

            setCubicTextureName(fullNames, forUVW);
        }
    }
Exemple #14
0
void ServerImpl::handleRegisterFiles(QHttpRequest *req, QHttpResponse *resp)
{
    req->storeBody();
    connect(req, &QHttpRequest::end,  [this, req, resp]() {
        QByteArray jsonTextBin = req->body();
        QJsonObject json = QJsonDocument::fromJson(jsonTextBin).object();
        QByteArray content("ok");
        if (!json.isEmpty()) {
            FileInfo fi;
            fi.filename = json["filename"].toString();
            fi.filepath = json["filepath"].toString();
            fi.hash = json["md5"].toString();
            fi.ttl = json["ttl"].toInt();
            fi.registeredTime = QDateTime::currentDateTime();

            if (!fi.filename.isEmpty() && !fi.hash.isEmpty() && QFile::exists(fi.filepath)) {
                mRegisteredFiles[fi.hash] = fi;
            }
        }

        resp->setHeader("Content-Length", QString::number(content.length()));
        setContentType(resp, "text/plain");
        resp->writeHead(200); // everything is OK
        resp->write(content);
        resp->end();
    });
}
    foreach (const QString &headerRow, headerLines) {
        QRegExp messageIdRx("^Message-ID: (.*)$", Qt::CaseInsensitive);
        QRegExp fromRx("^From: (.*)$", Qt::CaseInsensitive);
        QRegExp toRx("^To: (.*)$", Qt::CaseInsensitive);
        QRegExp ccRx("^Cc: (.*)$", Qt::CaseInsensitive);
        QRegExp subjectRx("^Subject: (.*)$", Qt::CaseInsensitive);
        QRegExp dateRx("^Date: (.*)$", Qt::CaseInsensitive);
        QRegExp mimeVerstionRx("^MIME-Version: (.*)$", Qt::CaseInsensitive);
        QRegExp contentTransferEncodingRx("^Content-Transfer-Encoding: (.*)$", Qt::CaseInsensitive);
        QRegExp contentTypeRx("^Content-Type: (.*)$", Qt::CaseInsensitive);

        if (messageIdRx.indexIn(headerRow) != -1)
            setMessageId(messageIdRx.cap(1));
        else if (fromRx.indexIn(headerRow) != -1)
            setFrom(headerDecode(fromRx.cap(1)));
        else if (toRx.indexIn(headerRow) != -1)
            setTo(headerDecode(toRx.cap(1)));
        else if (ccRx.indexIn(headerRow) != -1)
            setCc(headerDecode(ccRx.cap(1)));
        else if (subjectRx.indexIn(headerRow) != -1)
            setSubject(headerDecode(subjectRx.cap(1)));
        else if (dateRx.indexIn(headerRow) != -1) {
            QDateTime date = QDateTime::fromString(dateRx.cap(1), Qt::RFC2822Date);
            setDate(date);
        } else if (mimeVerstionRx.indexIn(headerRow) != -1)
            setMimeVersion(mimeVerstionRx.cap(1));
        else if (contentTransferEncodingRx.indexIn(headerRow) != -1)
            setContentTransferEncoding(IqPostmanAbstractContent::contentTransferEncodingFromString(headerRow));
        else if (contentTypeRx.indexIn(headerRow) != -1)
            setContentType(IqPostmanAbstractContentType::createFromString(headerRow));
    }
Exemple #16
0
void body::setContents(ref <const contentHandler> contents, const mediaType& type,
                       const charset& chset, const encoding& enc)
{
    m_contents = contents;

    setContentType(type, chset);
    setEncoding(enc);
}
Exemple #17
0
void MailMessage::makeMultipart()
{
	if (!isMultipart())
	{
		MediaType mediaType("multipart", "mixed");
		setContentType(mediaType);	
	}
}
Exemple #18
0
void HttpResponse::setHttp501Status() {
    setStatusCode(HTTP_METHODERROR);
    setContentType(CONTEXT_TYPE_HTML);
    addHeader("Server", JOINTCOM_FLAG);
    setBody("<HTML><TITLE>Method Not FOUND</TITLE>\r\n"
            "<BODY><P>(CODE: 501)</P>\r\n"
            "HTTP request method not supported.\r\n"
            "</BODY></HTML>\r\n");
}
ThreePeriodicMarkovChain::ThreePeriodicMarkovChain(BOOM::Vector<TrainingSequence*> &
						   sequences,int order,
						   int minSampleSize,
						   ContentType contentType)
{
  setContentType(contentType);
  setStrand(PLUS_STRAND);
  buildModels(sequences,minSampleSize,order);
}
Exemple #20
0
void HttpResponse::setHttp400Status() {
    setStatusCode(HTTP_REQERROR);
    setContentType(CONTEXT_TYPE_HTML);
    addHeader("Server", JOINTCOM_FLAG);
    setBody("<HTML><TITLE>Not Found</TITLE>\r\n"
            "<BODY><P>(CODE: 400)</P>\r\n"
            "Your browser sent a bad request.\r\n"
            "</BODY></HTML>\r\n");
}
Exemple #21
0
MHSyncItemInfo::MHSyncItemInfo(unsigned long id_,
                               const char* guid, 
                               const char* luid, 
                               const char* name, 
                               int64_t size,
                               const char* serverUrl,
                               const char* contentType, 
                               int64_t creationDate, 
                               int64_t modificationDate,
                               EItemInfoStatus status, 
                               time_t serverLastUpdate,
                               const char* remoteItemUrl,
                               const char* remoteThumbUrl,
                               const char* remotePreviewUrl,
                               const char* localThumbPath,
                               const char* localPreviewPath,
                               const char* localItemPath_,
                               const char* remoteItemETag,
                               const char* remoteThumbETag,
                               const char* remotePreviewETag)
{
    iD = id_;
    
    setGuid(guid);
    setLuid(luid);
    
    setName(name);
    this->size = size;
    
    setServerUrl(serverUrl);
    setContentType(contentType);

    this->creationDate = creationDate;
    this->modificationDate = modificationDate;

    this->status = status;
    this->serverLastUpdate  = serverLastUpdate; 

    setRemoteItemUrl(remoteItemUrl);
    setRemoteThumbUrl(remoteThumbUrl);
    setRemotePreviewUrl(remotePreviewUrl);
    setRemoteItemETag(remoteItemETag);
    setLocalThumbPath(localThumbPath);
    setLocalPreviewPath(localPreviewPath);
    setLocalItemPath(localItemPath_);
    setRemoteThumbETag(remoteThumbETag);
    setRemotePreviewETag(remotePreviewETag);
    
    setLocalItemETag("");
    setLocalPreviewETag("");
    setLocalThumbETag("");
    
    numUploadFailures = 0;
    exportedServices.clear();
    setValidationStatus(EValidationStatusUnknown);
}
Exemple #22
0
void HttpResponse::redirect(QString location, int status) {
  if (!d)
    return;
  setStatus(status);
  setHeader(QStringLiteral("Location"), location);
  setContentType(QStringLiteral("text/html;charset=UTF-8"));
  // LATER url encode
  output()->write(QStringLiteral(
                    "<html><body>Moved. Please click on <a href=\"%1"
                    "\">this link</a>").arg(location).toUtf8().constData());
}
/*!
  \~english
  \brief Constructor.

  \~japanese
  \brief コンストラクタ
 */
TActionController::TActionController()
    : QObject(),
      TAbstractController(),
      statCode(200),
      rendered(false),
      layoutEnable(true),
      rollback(false)
{
    // Default content type
    setContentType("text/html");
}
void ThreePeriodicMarkovChain::load(istream &is)
{
  BOOM::String dummy;
  for(int i=0 ; i<3 ; ++i)
    {
      is >> dummy;
      chains[i]=new MarkovChain(is);
    }
  ContentType contentType=chains[0]->getContentType();
  setContentType(contentType);
  setStrand(::getStrand(contentType));
}
    shared_ptr<ndn::Data>
    NdnDataManager::makeNack( const Data& data )
    {
        auto nack = make_shared<Data>( data.getName() );
        nack->setContentType( tlv::ContentType_Nack );
        nack->setContent( data.wireEncode() );
        nack->setAccessLevel( 0 );

        m_signer.sign( *nack );
        nack->wireEncode();
        return nack;
    }
void
Manifest::encode()
{
    EncodingEstimator estimator;
    size_t estimatedSize = wireEncode(estimator);

    EncodingBuffer buffer(estimatedSize, 0);
    wireEncode(buffer);

    setContentType(tlv::ContentType_Manifest);
    setContent(const_cast<uint8_t*>(buffer.buf()), buffer.size());
}
void TMailMessage::init(const QByteArray &encoding)
{
    QTextCodec *codec = QTextCodec::codecForName(encoding);
    textCodec = (codec) ? codec : QTextCodec::codecForName("UTF-8");
    // Sets default values
    setCurrentDate();
    QByteArray type = DEFAULT_CONTENT_TYPE;
    type += "; charset=\"";
    type += codec->name();
    type += '\"';
    setContentType(type);
}
Exemple #28
0
void HttpResponse::setHttp404Status(const char* error_msg) {
    setStatusCode(HTTP_NOTFAND);
    setContentType(CONTEXT_TYPE_HTML);
    addHeader("Server", JOINTCOM_FLAG);
    if (error_msg)
        setBody(error_msg);
    else
        setBody("<HTML><TITLE>Not Found</TITLE>\r\n"
            "<BODY><P>(CODE: 404)</P>\r\n"
            "the resource is unavailable or nonexistent.\r\n"
            "</BODY></HTML>\r\n");
}
void HttpResponseGenerator::setContentTypeByExt(const QString& ext) {
  if (ext == "css") {
		setContentType("text/css");
		return;
	}
  if (ext == "gif") {
		setContentType("image/gif");
		return;
	}
	if (ext == "htm" || ext == "html")	{
		setContentType("text/html");
		return;
	}
	if (ext == "js")	{
		setContentType("text/javascript");
		return;
	}
  if (ext == "png") {
		setContentType("image/x-png");
		return;
	}
}
bool HttpResponse::sendJsonObject(JsonObjectStream* newJsonStreamInstance)
{
	if (stream != NULL)
	{
		SYSTEM_ERROR("Stream already created");
		delete stream;
		stream = NULL;
	}

	stream = newJsonStreamInstance;
	if (!hasHeader("Content-Type"))
		setContentType(ContentType::JSON);
}