void Pillow::HttpClient::messageComplete() { delete _contentDecoder; _contentDecoder = 0; if (statusCode() == 100) { // Completely hide and ignore the 100 response we just received. clear(); } else { Pillow::HttpResponseParser::messageComplete(); _responsePending = false; if (_keepAliveTimeout == 0) _device->close(); else { if (!shouldKeepAlive()) _device->close(); _keepAliveTimeoutTimer.start(); } emit finished(); } }
status_t kill_child(pid_t pid) { int status; VLOG("try to kill child process %d", pid); kill(pid, SIGKILL); if (waitpid(pid, &status, 0) == -1) return -1; return statusCode(status); }
void Pillow::HttpClient::headersComplete() { Pillow::HttpResponseParser::headersComplete(); if (statusCode() == 100) return; emit headersCompleted(); if (Pillow::ByteArrayHelpers::asciiEqualsCaseInsensitive(_request.method, Pillow::LowerCaseToken("head"))) { pause(); messageComplete(); } else { for (int i = 0, iE = _headers.size(); i < iE; ++i) { const Pillow::HttpHeader& header = _headers.at(i); if (Pillow::ByteArrayHelpers::asciiEqualsCaseInsensitive(header.first, Pillow::LowerCaseToken("content-encoding"))) { if (Pillow::ByteArrayHelpers::asciiEqualsCaseInsensitive(header.second, Pillow::LowerCaseToken("gzip"))) _contentDecoder = new Pillow::GunzipContentTransformer(); } } } }
QValueList<Mirror> Sites::readFile(const QString& fileName) { QValueList<Mirror> result; QFile f(fileName); if (!f.open(IO_ReadOnly)) { kdDebug(60010) << "Couldn't read: " << fileName << endl; return result; } QTextStream ts(&f); if (statusCode(ts.readLine()) != 210) return result; while (!ts.atEnd()) { QString line = ts.readLine(); if (line == ".") break; result << parseLine(line); } return result; }
TInt CSenLocalTransportPlugin::SubmitL(const TDesC8& aEndpoint, const TDesC8& aMessage, const TDesC8& aTransportProperties, HBufC8*& apResponse, MSenRemoteServiceConsumer& /*aConsumer*/) { TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"CSenLocalTransportPlugin::SubmitL:"); // Sanity check the endpoint if (aEndpoint.Length() <= 0) { TLSLOG_L(KSenLocalTransportLogChannelBase,KMinLogLevel,"- No endpoint!"); return KErrSenNoEndpoint; // from SenServiceConnection.h (public API) } TLSLOG_FORMAT((KSenLocalTransportLogChannelBase,KMinLogLevel, _L8("- Endpoint: %S"), &aEndpoint)); TLSLOG_L(KSenLocalTransportLogChannelBase,KMaxLogLevel,"- Message:"); TLSLOG_ALL(KSenLocalTransportLogChannelBase,KMaxLogLevel,( aMessage )); TInt leaveCode(KErrNone); TInt statusCode(KErrNone); /* statusCode = ipRequester->SubmitL(aEndpoint, // endpoint aMessage, // request body aTransportProperties, // request props apResponse); */ TRAP( leaveCode, statusCode = ipRequester->SubmitL(aEndpoint, // endpoint aMessage, // request body aTransportProperties, // request props apResponse); ) // response body
CDDB::Result Lookup::parseRead( const QString & line ) { uint serverStatus = statusCode( line ); if ( 210 != serverStatus ) return ServerError; return Success; }
CDDB::Result Submit::parseWrite( const QString & line ) { uint serverStatus = statusCode( line ); if ( 320 != serverStatus ) return ServerError; return Success; }
status_t wait_child(pid_t pid) { int status; bool died = false; // wait for child to report status up to 1 seconds for (int loop = 0; !died && loop < WAIT_MAX; loop++) { if (waitpid(pid, &status, WNOHANG) == pid) died = true; // sleep for 0.2 second nanosleep(&WAIT_INTERVAL_NS, NULL); } if (!died) return kill_child(pid); return statusCode(status); }
bool CDDBPLookup::parseHandshake( const QString & line ) { uint serverStatus = statusCode( line ); if ( ( 200 != serverStatus ) && ( 402 != serverStatus ) ) { kDebug(60010) << "Handshake was too tight. Letting go."; return false; } kDebug(60010) << "Handshake was warm and firm"; return true; }
bool Pillow::HttpClient::redirected() const { switch (statusCode()) { case 300: // Multiple Choices case 301: // Moved Permanently case 302: // Found case 303: // See Other case 307: // Temporary Redirect return true; default: return false; } }
bool CDDBPLookup::parseGreeting( const QString & line ) { uint serverStatus = statusCode( line ); if ( 200 == serverStatus ) { kDebug(60010) << "Server response: read-only"; readOnly_ = true; } else if ( 201 == serverStatus ) { kDebug(60010) << "Server response: read-write"; } else { kDebug(60010) << "Server response: bugger off"; return false; } return true; }
CDDB::Result Lookup::parseQuery( const QString & line ) { uint serverStatus = statusCode( line ); if ( 200 == serverStatus ) { QStringList tokenList = QStringList::split( ' ', line ); matchList_.append( qMakePair( tokenList[ 1 ], tokenList[ 2 ] ) ); return Success; } else if ( ( 211 == serverStatus ) || ( 210 == serverStatus ) ) { return MultipleRecordFound; } else if ( 202 == serverStatus ) { return NoRecordFound; } return ServerError; }
void install() { //skip test, only makes sense when the test is very controlled return; const QString snap = QStringLiteral("nano-editor"); auto job = socket.snapByName(snap); QVERIFY(!job->exec() && job->statusCode() == 404); { const auto job = socket.snapAction(snap, SnapSocket::Install); QVERIFY(job && job->exec()); qDebug() << "installed" << job->result(); } QCOMPARE(jobResult(socket.snapByName(snap)).toObject().value(QStringLiteral("name")).toString(), snap); { const auto job = socket.snapAction(snap, SnapSocket::Remove); QVERIFY(job && job->exec()); qDebug() << "uninstalled" << job->result(); } QVERIFY(!socket.snapByName(snap)->exec()); }
// --------------------------------------------------------- // CNSmlCmdsBase::ProcessStatusCmdL // Handles Status command from a server. // --------------------------------------------------------- EXPORT_C void CNSmlCmdsBase::ProcessStatusCmdL( SmlStatus_t* aStatus ) { //msgRef if ( !aStatus->msgRef ) { return; } if ( !aStatus->msgRef->content ) { return; } TPtr8 msgRef( (TUint8*) aStatus->msgRef->content, aStatus->msgRef->length, aStatus->msgRef->length ); TrimRightSpaceAndNull( msgRef ); if ( msgRef.Length() == 0 ) { return; } //cmd if ( !aStatus->cmd ) { return; } if ( !aStatus->cmd->content ) { return; } TPtr8 cmd( (TUint8*) aStatus->cmd->content, aStatus->cmd->length, aStatus->cmd->length ); TrimRightSpaceAndNull( cmd ); if ( cmd.Length() == 0 ) { return; } //cmdRef HBufC8* cmdRef = NULL; if ( !aStatus->cmdRef ) { if ( cmd == KNSmlAgentSyncHdr ) { cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); *cmdRef = KNSmlAgentSyncHdrCmdID; } else { return; } } else if ( !aStatus->cmdRef->content ) { if ( cmd == KNSmlAgentSyncHdr ) { cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); *cmdRef = KNSmlAgentSyncHdrCmdID; } else { return; } } else { TPtr8 cmdRefPtr ( (TUint8*) aStatus->cmdRef->content, aStatus->cmdRef->length, aStatus->cmdRef->length ); TrimRightSpaceAndNull( cmdRefPtr ); if ( cmdRefPtr.Length() == 0 ) { if ( cmd == KNSmlAgentSyncHdr ) { cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); *cmdRef = KNSmlAgentSyncHdrCmdID; } else { return; } } else { cmdRef = HBufC8::NewLC( cmdRefPtr.Length() ); *cmdRef = cmdRefPtr; } } // Status code TPtr8 statusCode( (TUint8*) aStatus->data->content, aStatus->data->length, aStatus->data->length ); TrimRightSpaceAndNull( statusCode ); if ( statusCode.Length() == 0 ) { CleanupStack::PopAndDestroy(); //cmdRef return; } TLex8 lexicalStatus( statusCode ); TInt numericStatus; if ( lexicalStatus.Val (numericStatus ) != KErrNone ) { CleanupStack::PopAndDestroy(); //cmdRef return; } TInt entryID = 0; TBool statusIsMatching; statusIsMatching = iResponseController->MatchStatusElement( msgRef, *cmdRef , numericStatus, entryID ); if ( !statusIsMatching ) { } else { // chal element is stored for later use if ( aStatus->chal ) { if ( aStatus->chal->meta ) { if ( aStatus->chal->meta->content && aStatus->chal->meta->contentType == SML_PCDATA_EXTENSION && aStatus->chal->meta->extension == SML_EXT_METINF ) { SmlMetInfMetInf_t* metInf; metInf = (SmlMetInfMetInf_t*) aStatus->chal->meta->content; if ( metInf->type ) { if ( metInf->type->content ) { TPtr8 chalType( (TUint8*) metInf->type->content, metInf->type->length, metInf->type->length ); TrimRightSpaceAndNull( chalType ); if ( chalType.Length() > 0 ) { iResponseController->SetChalTypeL( entryID, chalType ); } } } if ( metInf->format ) { if ( metInf->format->content ) { TPtr8 chalFormat( (TUint8*) metInf->format->content, metInf->format->length, metInf->format->length ); TrimRightSpaceAndNull( chalFormat ); if ( chalFormat.Length() > 0 ) { iResponseController->SetChalFormatL( entryID, chalFormat ); } else { iResponseController->SetChalFormatL( entryID, KNSmlAgentChrFormat ); } } else { iResponseController->SetChalFormatL( entryID, KNSmlAgentChrFormat ); } } else { iResponseController->SetChalFormatL( entryID, KNSmlAgentChrFormat ); } if ( metInf->nextnonce ) { if ( metInf->nextnonce->content ) { TPtr8 chalNextNonce( (TUint8*) metInf->nextnonce->content, metInf->nextnonce->length, metInf->nextnonce->length ); TrimRightSpaceAndNull( chalNextNonce ); if ( chalNextNonce.Length() > 0 ) { iResponseController->SetChalNextNonceL( entryID, chalNextNonce ); } } } } } } } CleanupStack::PopAndDestroy(); //cmdRef if ( statusIsMatching ) { iAgent->CheckServerStatusCodeL( entryID ); } }
QString FlightStatuses::statusCodeString() const { return toString(statusCode()); }