virtual void completedHeaders(U32 status, std::string const& reason, AIHTTPReceivedHeaders const& headers)
	  {
		  if (200 <= status && status < 300)
		  {
			  std::string media_type;
			  if (headers.getFirstValue("content-type", media_type))
			  {
				  std::string::size_type idx1 = media_type.find_first_of(";");
				  std::string mime_type = media_type.substr(0, idx1);
				  completeAny(status, mime_type);
				  return;
			  }
			  llwarns << "LLMediaTypeResponder::completedHeaders: OK HTTP status (" << status << ") but no Content-Type! Received headers: " << headers << llendl;
		  }
		  completeAny(status, "none/none");
	  }
Ejemplo n.º 2
0
bool LLAvatarNameCache::expirationFromCacheControl(AIHTTPReceivedHeaders const& headers, F64* expires)
{
	bool fromCacheControl = false;
	F64 now = LLFrameTimer::getTotalSeconds();
	// Allow the header to override the default
	std::string cache_control;
	if (headers.getFirstValue("cache-control", cache_control))
	{
		S32 max_age = 0;
		if (max_age_from_cache_control(cache_control, &max_age))
		{
			*expires = now + (F64)max_age;
			fromCacheControl = true;
		}
	}
	LL_DEBUGS("AvNameCache")
		<< ( fromCacheControl ? "expires based on cache control " : "default expiration " )
		<< "in " << *expires - now << " seconds"
		<< LL_ENDL;

	return fromCacheControl;
}
Ejemplo n.º 3
0
	/*virtual*/ void completedHeaders(U32 status, std::string const& reason, AIHTTPReceivedHeaders const& received_headers)
	{
		// Server abuses 303 status; Curl can't handle it because it tries to resent
		// the just uploaded data, which fails
		// (CURLE_SEND_FAIL_REWIND: Send failed since rewinding of the data stream failed).
		// Handle it manually.
		if (status == 303)
		{
			AIHTTPHeaders headers;
			headers.addHeader("Accept", "*/*");
			headers.addHeader("Cookie", LLWebProfile::getAuthCookie());
			headers.addHeader("User-Agent", LLViewerMedia::getCurrentUserAgent());
			std::string redir_url;
			received_headers.getFirstValue("location", redir_url);
			LL_DEBUGS("Snapshots") << "Got redirection URL: " << redir_url << LL_ENDL;
			LLHTTPClient::get(redir_url, new LLWebProfileResponders::PostImageRedirectResponder, headers);
		}
		else
		{
			llwarns << "Unexpected POST status: " << status << " " << reason << llendl;
			LL_DEBUGS("Snapshots") << "received_headers: [" << received_headers << "]" << LL_ENDL;
			LLWebProfile::reportImageUploadStatus(false);
		}
	}