Exemplo n.º 1
0
int CCrawl::login(const string &loginurl, const string &postdata)
{
	int statuscode = POST_data_Html(loginurl, postdata);
	string headers;
	getResponseHeaders(headers);
	cout<<headers<<endl;
	return statuscode;
}
Exemplo n.º 2
0
		// Return time to retry a request that generated an error, based on
		// error type and headers.  Return value is seconds-since-epoch.
		F64 errorRetryTimestamp(S32 status)
		{

			// Retry-After takes priority
			LLSD retry_after = getResponseHeaders()["retry-after"];
			if (retry_after.isDefined())
			{
				// We only support the delta-seconds type
				S32 delta_seconds = retry_after.asInteger();
				if (delta_seconds > 0)
				{
					// ...valid delta-seconds
					return F64(delta_seconds);
				}
			}

			// If no Retry-After, look for Cache-Control max-age
			F64 expires = 0.0;
			if (LLExperienceCache::expirationFromCacheControl(getResponseHeaders(), &expires))
			{
				return expires;
			}

			// No information in header, make a guess
			if (status == 503)
			{
				// ...service unavailable, retry soon
				const F64 SERVICE_UNAVAILABLE_DELAY = 600.0; // 10 min
				return SERVICE_UNAVAILABLE_DELAY;
			}
			else if (status == 499)
			{
				// ...we were probably too busy, retry quickly
				const F64 BUSY_DELAY = 10.0; // 10 seconds
				return BUSY_DELAY;

			}
			else
			{
				// ...other unexpected error
				const F64 DEFAULT_DELAY = 3600.0; // 1 hour
				return DEFAULT_DELAY;
			}
		}
Exemplo n.º 3
0
	/*virtual*/ void httpSuccess()
	{
		const LLSD& content = getContent();
		if (!content.isMap())
		{
			failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
			return;
		}
		// Pull expiration out of headers if available
		F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(getResponseHeaders());
		F64 now = LLFrameTimer::getTotalSeconds();

		const LLSD& agents = content["agents"];
		LLSD::array_const_iterator it = agents.beginArray();
		for ( ; it != agents.endArray(); ++it)
		{
			const LLSD& row = *it;
			LLUUID agent_id = row["id"].asUUID();

			LLAvatarName av_name;
			av_name.fromLLSD(row);

			// Use expiration time from header
			av_name.mExpires = expires;

			LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << LL_ENDL;
			av_name.dump();
			
			// cache it and fire signals
			LLAvatarNameCache::processName(agent_id, av_name);
		}

		// Same logic as error response case
		const LLSD& unresolved_agents = content["bad_ids"];
		S32  num_unresolved = unresolved_agents.size();
		if (num_unresolved > 0)
		{
            LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; "
                                    << "expires in " << expires - now << " seconds"
                                    << LL_ENDL;
			it = unresolved_agents.beginArray();
			for ( ; it != unresolved_agents.endArray(); ++it)
			{
				const LLUUID& agent_id = *it;

				LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result "
                                        << "failed id " << agent_id
                                        << LL_ENDL;

                LLAvatarNameCache::handleAgentError(agent_id);
			}
		}
        LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result " 
                                 << LLAvatarNameCache::sCache.size() << " cached names"
                                 << LL_ENDL;
    }
	void completedHeader()
	{
		LLSD content = getResponseHeaders();
		LL_DEBUGS("fsdata") << "Status: [" << getStatus() << "]: " << "last-modified: " << content["last-modified"].asString() << LL_ENDL; //  Wed, 21 Mar 2012 17:41:14 GMT
		if (content.has("last-modified"))
		{
			mLastModified.secondsSinceEpoch(FSCommon::secondsSinceEpochFromString("%a, %d %b %Y %H:%M:%S %ZP", content["last-modified"].asString()));
		}
		LL_DEBUGS("fsdata") << "Converted to: " << mLastModified.asString() << " and RFC1123: " << mLastModified.asRFC1123() << LL_ENDL;
	}
/*virtual*/
void AISCommand::httpFailure()
{
	LL_WARNS("Inventory") << dumpResponse() << LL_ENDL;
	S32 status = getStatus();
	const LLSD& headers = getResponseHeaders();
	mRetryPolicy->onFailure(status, headers);
	F32 seconds_to_wait;
	if (mRetryPolicy->shouldRetry(seconds_to_wait))
	{
		doAfterInterval(boost::bind(&AISCommand::run_command,this),seconds_to_wait);
	}
	else
	{
		// Command func holds a reference to self, need to release it
		// after a success or final failure.
		// *TODO: Notify user?  This seems bad.
		setCommandFunc(no_op);
	}
}