ExceptionOr<void> XMLHttpRequest::send(DOMFormData& body) { if (auto result = prepareToSend()) return WTFMove(result.value()); if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { m_requestEntityBody = FormData::createMultiPart(body, body.encoding(), document()); m_requestEntityBody->generateFiles(document()); if (!m_requestHeaders.contains(HTTPHeaderName::ContentType)) m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data())); } return createRequest(); }
WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient) { m_data.pageGroupID = generatePageGroupID(); if (!identifier.isEmpty()) m_data.identifer = identifier; else m_data.identifer = m_data.identifer = makeString("__uniquePageGroupID-", String::number(m_data.pageGroupID)); m_data.visibleToInjectedBundle = visibleToInjectedBundle; m_data.visibleToHistoryClient = visibleToHistoryClient; webPageGroupMap().set(m_data.pageGroupID, this); }
void InspectorConsoleAgent::startTiming(const String& title) { ASSERT(!title.isNull()); if (title.isNull()) return; auto result = m_times.add(title, monotonicallyIncreasingTime()); if (!result.isNewEntry) { // FIXME: Send an enum to the frontend for localization? String warning = makeString("Timer \"", title, "\" already exists"); addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning)); } }
RefPtr<WebCore::IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext*, const Vector<String>& objectStores, const String& modeString, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBDatabase::transaction"); if (m_closePending) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing."); return nullptr; } if (objectStores.isEmpty()) { ec.code = IDBDatabaseException::InvalidAccessError; ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty."); return nullptr; } IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, ec.code); if (ec.code) { ec.message = makeString(ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('"), modeString, ASCIILiteral("') is not one of 'readonly' or 'readwrite'.")); return nullptr; } if (mode != IndexedDB::TransactionMode::ReadOnly && mode != IndexedDB::TransactionMode::ReadWrite) { ec.code = TypeError; return nullptr; } if (m_versionChangeTransaction && !m_versionChangeTransaction->isFinishedOrFinishing()) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running."); return nullptr; } for (auto& objectStoreName : objectStores) { if (m_info.hasObjectStore(objectStoreName)) continue; ec.code = IDBDatabaseException::NotFoundError; ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found."); return nullptr; } auto info = IDBTransactionInfo::clientTransaction(m_serverConnection.get(), objectStores, mode); auto transaction = IDBTransaction::create(*this, info); LOG(IndexedDB, "IDBDatabase::transaction - Added active transaction %s", info.identifier().loggingString().utf8().data()); m_activeTransactions.set(info.identifier(), &transaction.get()); return adoptRef(&transaction.leakRef()); }
// Compatibility hack for the Optimost JavaScript library. (See <rdar://problem/6595040>.) static inline void insertSemicolonIfNeeded(String& functionBody) { ASSERT(functionBody[0] == '{'); ASSERT(functionBody[functionBody.length() - 1] == '}'); for (size_t i = functionBody.length() - 2; i > 0; --i) { UChar ch = functionBody[i]; if (!Lexer<UChar>::isWhiteSpace(ch) && !Lexer<UChar>::isLineTerminator(ch)) { if (ch != ';' && ch != '}') functionBody = makeString(functionBody.substringSharingImpl(0, i + 1), ";", functionBody.substringSharingImpl(i + 1, functionBody.length() - (i + 1))); return; } } }
void ContentSecurityPolicy::reportUnsupportedDirective(const String& name) const { String message; if (equalLettersIgnoringASCIICase(name, "allow")) message = ASCIILiteral("The 'allow' directive has been replaced with 'default-src'. Please use that directive instead, as 'allow' has no effect."); else if (equalLettersIgnoringASCIICase(name, "options")) message = ASCIILiteral("The 'options' directive has been replaced with 'unsafe-inline' and 'unsafe-eval' source expressions for the 'script-src' and 'style-src' directives. Please use those directives instead, as 'options' has no effect."); else if (equalLettersIgnoringASCIICase(name, "policy-uri")) message = ASCIILiteral("The 'policy-uri' directive has been removed from the specification. Please specify a complete policy via the Content-Security-Policy header."); else message = makeString("Unrecognized Content-Security-Policy directive '", name, "'.\n"); // FIXME: Why does this include a newline? logToConsole(message); }
void InspectorConsoleAgent::count(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) { const ScriptCallFrame& lastCaller = callStack->at(0); // Follow Firebug's behavior of counting with null and undefined title in // the same bucket as no argument String title; arguments->getFirstArgumentAsString(title); String identifier = makeString(title, '@', lastCaller.sourceURL(), ':', String::number(lastCaller.lineNumber())); HashMap<String, unsigned>::iterator it = m_counts.find(identifier); int count; if (it == m_counts.end()) count = 1; else { count = it->second + 1; m_counts.remove(it); } m_counts.add(identifier, count); String message = makeString(title, ": ", String::number(count)); addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lastCaller.lineNumber(), lastCaller.sourceURL()); }
static String windowsVersion() { String osVersion; OSVERSIONINFO versionInfo = { 0 }; versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); ::GetVersionEx(&versionInfo); if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { if (versionInfo.dwMajorVersion == 4) { if (versionInfo.dwMinorVersion == 0) osVersion = "Windows 95"; else if (versionInfo.dwMinorVersion == 10) osVersion = "Windows 98"; else if (versionInfo.dwMinorVersion == 90) osVersion = "Windows 98; Win 9x 4.90"; } } else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) osVersion = makeString("Windows NT ", String::number(versionInfo.dwMajorVersion), '.', String::number(versionInfo.dwMinorVersion)); if (!osVersion.length()) osVersion = makeString("Windows ", String::number(versionInfo.dwMajorVersion), '.', String::number(versionInfo.dwMinorVersion)); return osVersion; }
std::string UniqueOrderId::get(char moduleId) { boost::mutex::scoped_lock lock(_mutex); if (UniqueOrderId::_orderId == 0) { // First time being read, se if anything in the file _fileName = moduleId; _fileName += "-"; _fileName += "orderNumber.txt"; ifstream inputFile(_fileName.c_str()); if ( inputFile.is_open() ) { std::string line, previousLine; while (true) { getline(inputFile, line); if ( line.empty() ) { break; } else { previousLine = line; } } _orderId = atoi(previousLine.c_str()); inputFile.close(); } else { std::cout << std::endl << "~!~!~!~!!~!~!~ NO FILE ~!~!~!~!!~!~!~ " << std::endl; } _outputFile.open(_fileName.c_str()); } _orderId++; _outputFile << _orderId << std::endl; _outputFile.flush(); boost::posix_time::time_facet *facet = new boost::posix_time::time_facet("%Y%m%d"); std::stringstream ss; ss.imbue(locale(ss.getloc(), facet)); ss << boost::posix_time::second_clock::local_time(); if (_date == "" || _date != ss.str()) { _date = ss.str(); //_orderId = 1; } return makeString(moduleId); }
static UString createErrorMessage(ExecState* exec, CodeBlock* codeBlock, int, int expressionStart, int expressionStop, JSValue value, UString error) { if (!expressionStop || expressionStart > codeBlock->source()->length()) return makeString(value.toString(exec), " is ", error); if (expressionStart < expressionStop) return makeString("Result of expression '", codeBlock->source()->getRange(expressionStart, expressionStop), "' [", value.toString(exec), "] is ", error, "."); // No range information, so give a few characters of context const UChar* data = codeBlock->source()->data(); int dataLength = codeBlock->source()->length(); int start = expressionStart; int stop = expressionStart; // Get up to 20 characters of context to the left and right of the divot, clamping to the line. // then strip whitespace. while (start > 0 && (expressionStart - start < 20) && data[start - 1] != '\n') start--; while (start < (expressionStart - 1) && isStrWhiteSpace(data[start])) start++; while (stop < dataLength && (stop - expressionStart < 20) && data[stop] != '\n') stop++; while (stop > expressionStart && isStrWhiteSpace(data[stop])) stop--; return makeString("Result of expression near '...", codeBlock->source()->getRange(start, stop), "...' [", value.toString(exec), "] is ", error, "."); }
String standardUserAgent(const String& applicationName, const String& applicationVersion) { const String& version = ASCIILiteral(versionForUAString()); static NeverDestroyed<String> standardUserAgentString = makeString("Mozilla/5.0 (", platformForUAString(), "; ", platformVersionForUAString(), ") AppleWebKit/", version, " (KHTML, like Gecko) Version/8.0 Safari/601.2.7"); if (applicationName.isEmpty()) return standardUserAgentString; String finalApplicationVersion = applicationVersion; if (finalApplicationVersion.isEmpty()) finalApplicationVersion = ASCIILiteral(versionForUAString()); return standardUserAgentString + ' ' + applicationName + '/' + finalApplicationVersion; }
CallIdentifier Profiler::createCallIdentifier(TiExcState* exec, TiValue functionValue, const UString& defaultSourceURL, int defaultLineNumber) { if (!functionValue) return CallIdentifier(GlobalCodeExecution, defaultSourceURL, defaultLineNumber); if (!functionValue.isObject()) return CallIdentifier("(unknown)", defaultSourceURL, defaultLineNumber); if (asObject(functionValue)->inherits(&TiFunction::info)) { TiFunction* function = asFunction(functionValue); if (!function->executable()->isHostFunction()) return createCallIdentifierFromFunctionImp(exec, function); } if (asObject(functionValue)->inherits(&InternalFunction::info)) return CallIdentifier(static_cast<InternalFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber); return CallIdentifier(makeString("(", asObject(functionValue)->className(), " object)"), defaultSourceURL, defaultLineNumber); }
void MixedContentChecker::checkFormForMixedContent(SecurityOrigin* securityOrigin, const URL& url) const { // Unconditionally allow javascript: URLs as form actions as some pages do this and it does not introduce // a mixed content issue. if (protocolIsJavaScript(url)) return; if (!isMixedContent(securityOrigin, url)) return; String message = makeString("The page at ", m_frame.document()->url().stringCenterEllipsizedToLength(), " contains a form which targets an insecure URL ", url.stringCenterEllipsizedToLength(), ".\n"); m_frame.document()->addConsoleMessage(MessageSource::Security, MessageLevel::Warning, message); client().didDisplayInsecureContent(); }
JSString* errorDescriptionForValue(ExecState* exec, JSValue v) { if (v.isString()) return jsNontrivialString(exec, makeString('"', asString(v)->value(exec), '"')); if (v.isSymbol()) return jsNontrivialString(exec, asSymbol(v)->descriptiveString()); if (v.isObject()) { CallData callData; JSObject* object = asObject(v); if (object->methodTable()->getCallData(object, callData) != CallType::None) return exec->vm().smallStrings.functionString(); return jsString(exec, JSObject::calculatedClassName(object)); } return v.toString(exec); }
// // ::doFormatLiteral // void doFormatLiteral(ObjectVector *objects, std::string &s) { if(s.size() == 1) { makeChar(objects, s[0]); objects->addToken(OCODE_ACSP_CHARACTER); } else if(!s.empty()) { makeString(objects, s); objects->addToken(OCODE_ACSP_STR); } s.clear(); }
void ProcessLauncher::launchProcess() { int sockets[2]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) { ASSERT_NOT_REACHED(); return; } pid_t pid = fork(); if (!pid) { // child process close(sockets[1]); String socket = String::format("%d", sockets[0]); String executablePath; switch (m_launchOptions.processType) { case WebProcess: executablePath = executablePathOfWebProcess(); break; case PluginProcess: executablePath = executablePathOfPluginProcess(); break; default: ASSERT_NOT_REACHED(); return; } #ifndef NDEBUG if (m_launchOptions.processCmdPrefix.isEmpty()) #endif execl(executablePath.utf8().data(), executablePath.utf8().data(), socket.utf8().data(), static_cast<char*>(0)); #ifndef NDEBUG else { String cmd = makeString(m_launchOptions.processCmdPrefix, ' ', executablePath, ' ', socket); if (system(cmd.utf8().data()) == -1) { ASSERT_NOT_REACHED(); return; } } #endif } else if (pid > 0) { // parent process; close(sockets[0]); m_processIdentifier = pid; // We've finished launching the process, message back to the main run loop. RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, pid, sockets[1])); } else { ASSERT_NOT_REACHED(); return; } }
void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec) { if (!initSend(ec)) return; if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { m_requestEntityBody = FormData::createMultiPart(*(static_cast<FormDataList*>(body)), body->encoding(), document()); m_requestEntityBody->generateFiles(document()); if (!m_requestHeaders.contains(HTTPHeaderName::ContentType)) m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data())); } createRequest(ec); }
JSCustomGetterSetterFunction* JSCustomGetterSetterFunction::create(VM& vm, JSGlobalObject* globalObject, CustomGetterSetter* getterSetter, const Type type, const PropertyName& propertyName) { ASSERT(type == Type::Getter ? !!getterSetter->getter() : !!getterSetter->setter()); const char* prefix = (type == Type::Getter) ? "get " : "set "; String name = makeString(prefix, String(propertyName.publicName())); NativeExecutable* executable = vm.getHostFunction(customGetterSetterFunctionCall, callHostFunctionAsConstructor, String(propertyName.publicName())); Structure* structure = globalObject->customGetterSetterFunctionStructure(); JSCustomGetterSetterFunction* function = new (NotNull, allocateCell<JSCustomGetterSetterFunction>(vm.heap)) JSCustomGetterSetterFunction(vm, globalObject, structure, type, propertyName); // Can't do this during initialization because getHostFunction might do a GC allocation. function->finishCreation(vm, executable, getterSetter, name); return function; }
bool RocksSortedDataImpl::unindex(OperationContext* txn, const BSONObj& key, const DiskLoc& loc) { RocksRecoveryUnit* ru = RocksRecoveryUnit::getRocksRecoveryUnit(txn); const string keyData = makeString( key, loc ); string dummy; if (ru->Get(_columnFamily.get(), keyData, &dummy).IsNotFound()) { return false; } ru->registerChange(new ChangeNumEntries(&_numEntries, false)); ru->writeBatch()->Delete(_columnFamily.get(), keyData); return true; }
static WebPageGroupData pageGroupData(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient) { WebPageGroupData data; data.pageGroupID = generatePageGroupID(); if (!identifier.isEmpty()) data.identifier = identifier; else data.identifier = makeString("__uniquePageGroupID-", String::number(data.pageGroupID)); data.visibleToInjectedBundle = visibleToInjectedBundle; data.visibleToHistoryClient = visibleToHistoryClient; return data; }
String platformDefaultLanguage() { static String computedDefaultLanguage; if (!computedDefaultLanguage.isEmpty()) return computedDefaultLanguage; String languageName = localeInfo(LOCALE_SISO639LANGNAME, "en"); String countryName = localeInfo(LOCALE_SISO3166CTRYNAME, String()); if (countryName.isEmpty()) computedDefaultLanguage = languageName; else computedDefaultLanguage = makeString(languageName, '-', countryName); return computedDefaultLanguage; }
bool PaymentRequestValidator::validateCountryCode(const String& countryCode) const { if (!countryCode) { m_window.printErrorMessage("Missing country code."); return false; } for (auto *countryCodePtr = uloc_getISOCountries(); *countryCodePtr; ++countryCodePtr) { if (countryCode == *countryCodePtr) return true; } auto message = makeString("\"" + countryCode, "\" is not a valid country code."); m_window.printErrorMessage(message); return false; }
static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0) { if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = false; unsigned length = propertyName.length(); if (!length) return String(); StringBuilder builder; builder.reserveCapacity(length); unsigned i = 0; if (hasCSSPropertyNamePrefix(propertyName, "css")) i += 3; else if (hasCSSPropertyNamePrefix(propertyName, "pixel")) { i += 5; if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = true; } else if (hasCSSPropertyNamePrefix(propertyName, "pos")) { i += 3; if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = true; } else if (hasCSSPropertyNamePrefix(propertyName, "webkit") || hasCSSPropertyNamePrefix(propertyName, "khtml") || hasCSSPropertyNamePrefix(propertyName, "apple") || hasCSSPropertyNamePrefix(propertyName, "epub")) builder.append('-'); else { if (isASCIIUpper(propertyName.characters()[0])) return String(); } builder.append(toASCIILower(propertyName.characters()[i++])); for (; i < length; ++i) { UChar c = propertyName.characters()[i]; if (!isASCIIUpper(c)) builder.append(c); else builder.append(makeString('-', toASCIILower(c))); } return builder.toString(); }
void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise) { // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script if (!m_loaders.remove(&loader)) return; loader.clearClient(); auto& cachedScript = *loader.cachedScript(); bool failed = false; if (cachedScript.resourceError().isAccessControl()) { promise->reject(TypeError, ASCIILiteral("Cross-origin script load denied by Cross-Origin Resource Sharing policy.")); return; } if (cachedScript.errorOccurred()) failed = true; else if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(cachedScript.response().mimeType())) { // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script // The result of extracting a MIME type from response's header list (ignoring parameters) is not a JavaScript MIME type. // For historical reasons, fetching a classic script does not include MIME type checking. In contrast, module scripts will fail to load if they are not of a correct MIME type. promise->reject(TypeError, makeString("'", cachedScript.response().mimeType(), "' is not a valid JavaScript MIME type.")); return; } auto* frame = m_document.frame(); if (!frame) return; if (failed) { // Reject a promise to propagate the error back all the way through module promise chains to the script element. promise->reject(frame->script().moduleLoaderAlreadyReportedErrorSymbol()); return; } if (cachedScript.wasCanceled()) { promise->reject(frame->script().moduleLoaderFetchingIsCanceledSymbol()); return; } m_requestURLToResponseURLMap.add(cachedScript.url(), cachedScript.response().url()); // FIXME: Let's wrap around ScriptSourceCode to propagate it directly through the module pipeline. promise->resolve<IDLDOMString>(ScriptSourceCode(&cachedScript, JSC::SourceProviderSourceType::Module).source().toString()); }
Vector<String> listDirectory(const String& directory, const String& filter) { Vector<String> entries; PathWalker walker(directory, filter); if (!walker.isValid()) return entries; do { if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; entries.append(makeString(directory, "\\", reinterpret_cast<const UChar*>(walker.data().cFileName))); } while (walker.step()); return entries; }
void addArgument( // puts s in vector char *s, unsigned count, char **vector[] ) { if (!(*vector)) { *vector = (char**) allocate(CHUNKSIZE*sizeof(char*)); } else if (!(count % CHUNKSIZE)) { *vector = (char**) REALLOC(*vector,(count+CHUNKSIZE)*sizeof(char*)); if (!*vector) { makeError(0,OUT_OF_MEMORY); } } (*vector)[count] = makeString(s); }
void didReceiveResponse(ResourceHandle*, const ResourceResponse& response) { m_response = adoptGRef(response.toSoupMessage()); m_download->didReceiveResponse(response); if (response.httpStatusCode() >= 400) { downloadFailed(platformDownloadNetworkError(response.httpStatusCode(), response.url().string(), response.httpStatusText())); return; } String suggestedFilename = response.suggestedFilename(); if (suggestedFilename.isEmpty()) { URL url = response.url(); url.setQuery(String()); url.removeFragmentIdentifier(); suggestedFilename = decodeURLEscapeSequences(url.lastPathComponent()); } bool overwrite; String destinationURI = m_download->decideDestinationWithSuggestedFilename(suggestedFilename, overwrite); if (destinationURI.isEmpty()) { #if PLATFORM(GTK) GOwnPtr<char> buffer(g_strdup_printf(_("Cannot determine destination URI for download with suggested filename %s"), suggestedFilename.utf8().data())); String errorMessage = String::fromUTF8(buffer.get()); #else String errorMessage = makeString("Cannot determine destination URI for download with suggested filename ", suggestedFilename); #endif downloadFailed(platformDownloadDestinationError(response, errorMessage)); return; } GRefPtr<GFile> file = adoptGRef(g_file_new_for_uri(destinationURI.utf8().data())); GOwnPtr<GError> error; m_outputStream = adoptGRef(g_file_replace(file.get(), 0, TRUE, G_FILE_CREATE_NONE, 0, &error.outPtr())); if (!m_outputStream) { downloadFailed(platformDownloadDestinationError(response, error->message)); return; } GRefPtr<GFileInfo> info = adoptGRef(g_file_info_new()); g_file_info_set_attribute_string(info.get(), "metadata::download-uri", response.url().string().utf8().data()); g_file_set_attributes_async(file.get(), info.get(), G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, 0, 0, 0); m_download->didCreateDestination(destinationURI); }
void readCommandFile( char *name ) { char *s, // buffer **vector; // local versions of arg vector unsigned count = 0; // count size_t n; if (!(file = FILEOPEN(name,"rt"))) makeError(0,CANT_OPEN_FILE,name); vector = NULL; // no args yet while (fgets(buf,MAXBUF,file)) { n = _tcslen(buf); // if we didn't get the whole line, OR the line ended with a backSlash if ((n == MAXBUF-1 && buf[n-1] != '\n') || (buf[n-1] == '\n' && buf[n-2] == '\\') ) { if (buf[n-2] == '\\' && buf[n-1] == '\n') { // Replace \n by \0 and \\ by a space; Also reset length buf[n-1] = '\0'; buf[n-2] = ' '; n--; } s = makeString(buf); getRestOfLine(&s,&n); } else s = buf; processLine(s,&count,&vector); // separate into args if (s != buf) FREE(s); } if (fclose(file) == EOF) makeError(0, ERROR_CLOSING_FILE, name); parseCommandLine(count,vector); // evaluate the args while (count--) // free the arg vector if(vector[count]) FREE(vector[count]); // NULL entries mean that the space the } // entry used to pt to is still in use
void MainWindow::deleteStudent() { if (current_db_class == NULL) { return; } if (CLLSListWidget->highlightedRow() < 0) { return; } switch (QMessageBox::information(this, tr("Delete student"), tr("Are you sure you want to delete student \"%1\"?").arg(CLLSListWidget->highlightedItem()->text()), tr("&Delete"), tr("Cancel"), 0, 1)) { case 0: // Delete break; case 1: // Cancel return; break; } current_db_class->removeMember(CLLSListWidget->highlightedRow()); delete CLLSListWidget->takeItem(CLLSListWidget->highlightedRow()); CLSCNumStudentsLabel->setText(makeString(current_db_class->numMembers())); CLSCAverageLabel->setText(QString("%1%").arg(current_db_class->average(¤t_db_sessions, ¤t_db_archivedsessions))); clearCLSS(); togglePrintEnabled(); setDatabaseModified(); }
int WebSocketHandshake::readServerHandshake(const char* header, size_t len) { m_mode = Incomplete; int statusCode; String statusText; int lineLength = readStatusLine(header, len, statusCode, statusText); if (lineLength == -1) return -1; if (statusCode == -1) { m_mode = Failed; // m_failureReason is set inside readStatusLine(). return len; } LOG(Network, "WebSocketHandshake %p readServerHandshake() Status code is %d", this, statusCode); m_serverHandshakeResponse = ResourceResponse(); m_serverHandshakeResponse.setHTTPStatusCode(statusCode); m_serverHandshakeResponse.setHTTPStatusText(statusText); if (statusCode != 101) { m_mode = Failed; m_failureReason = makeString("Unexpected response code: ", String::number(statusCode)); return len; } m_mode = Normal; if (!strnstr(header, "\r\n\r\n", len)) { // Just hasn't been received fully yet. m_mode = Incomplete; return -1; } const char* p = readHTTPHeaders(header + lineLength, header + len); if (!p) { LOG(Network, "WebSocketHandshake %p readServerHandshake() readHTTPHeaders() failed", this); m_mode = Failed; // m_failureReason is set inside readHTTPHeaders(). return len; } if (!checkResponseHeaders()) { LOG(Network, "WebSocketHandshake %p readServerHandshake() checkResponseHeaders() failed", this); m_mode = Failed; return p - header; } m_mode = Connected; return p - header; }