本文整理汇总了C#中System.Net.Http.HttpResponseMessage.WriteNoCache方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseMessage.WriteNoCache方法的具体用法?C# HttpResponseMessage.WriteNoCache怎么用?C# HttpResponseMessage.WriteNoCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpResponseMessage
的用法示例。
在下文中一共展示了HttpResponseMessage.WriteNoCache方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateResponse
private HttpResponseMessage CreateResponse(MemoryStream stream, string mediaType)
{
_tracer.Trace("Writing {0} bytes", stream.Length);
HttpContent content = stream.AsContent();
content.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
// REVIEW: Why is it that we do not write an empty Content-Type here, like for InfoRefsController?
var response = new HttpResponseMessage();
response.Content = content;
response.WriteNoCache();
return response;
}
示例2: SmartInfoRefs
private HttpResponseMessage SmartInfoRefs(string service)
{
using (_tracer.Step("InfoRefsService.SmartInfoRefs"))
{
var memoryStream = new MemoryStream();
memoryStream.PktWrite("# service=git-{0}\n", service);
memoryStream.PktFlush();
if (service == "upload-pack")
{
//// Initialize the repository from the deployment files (if this is the first commit)
//ChangeSet changeSet = _gitServer.Initialize(_configuration, _webRootPath);
//_gitServer.AdvertiseUploadPack(memoryStream);
//// If we just created the repo, make a 'pseudo' deployment for the initial commit
//if (changeSet != null)
//{
// _deploymentManager.CreateExistingDeployment(changeSet.Id, _configuration.Username);
//}
_gitServer.Initialize();
_gitServer.AdvertiseUploadPack(memoryStream);
}
else if (service == "receive-pack")
{
_gitServer.Initialize();
_gitServer.AdvertiseReceivePack(memoryStream);
}
_tracer.Trace("Writing {0} bytes", memoryStream.Length);
HttpContent content = memoryStream.AsContent();
content.Headers.ContentType =
new MediaTypeHeaderValue("application/x-git-{0}-advertisement".With(service));
// Explicitly set the charset to empty string
// We do this as certain git clients (jgit) require it to be empty.
// If we don't set it, then it defaults to utf-8, which breaks jgit's logic for detecting smart http
content.Headers.ContentType.CharSet = "";
var responseMessage = new HttpResponseMessage();
responseMessage.Content = content;
responseMessage.WriteNoCache();
return responseMessage;
}
}
示例3: SmartInfoRefs
private HttpResponseMessage SmartInfoRefs(string service)
{
using (_tracer.Step("InfoRefsService.SmartInfoRefs"))
{
var memoryStream = new MemoryStream();
memoryStream.PktWrite("# service=git-{0}\n", service);
memoryStream.PktFlush();
if (service == "upload-pack")
{
// Initialize the repository from the deployment files (if this is the first commit)
_gitServer.Initialize(_configuration, _deploymentTargetPath);
_gitServer.AdvertiseUploadPack(memoryStream);
}
else if (service == "receive-pack")
{
_gitServer.Initialize(_configuration);
_gitServer.AdvertiseReceivePack(memoryStream);
}
if (memoryStream.Length < 100)
{
_tracer.TraceWarning("Unexpected number of bytes written. {0} bytes", memoryStream.Length);
}
else
{
_tracer.Trace("Writing {0} bytes", memoryStream.Length);
}
// TODO: Should we only do this in debug mode?
_tracer.Trace("Git stream", new Dictionary<string, string>
{
{ "type", "gitStream" },
{ "output", Encoding.UTF8.GetString(memoryStream.ToArray()) }
});
HttpContent content = memoryStream.AsContent();
content.Headers.ContentType =
new MediaTypeHeaderValue("application/x-git-{0}-advertisement".With(service));
// Explicitly set the charset to empty string
// We do this as certain git clients (jgit) require it to be empty.
// If we don't set it, then it defaults to utf-8, which breaks jgit's logic for detecting smart http
content.Headers.ContentType.CharSet = "";
var responseMessage = new HttpResponseMessage();
responseMessage.Content = content;
responseMessage.WriteNoCache();
return responseMessage;
}
}
示例4: CreateResponse
private HttpResponseMessage CreateResponse(MemoryStream stream, string mediaType)
{
_tracer.Trace("Writing {0} bytes", stream.Length);
// TODO: Should we only do this in debug mode?
_tracer.Trace("Git stream", new Dictionary<string, string>
{
{ "type", "gitStream" },
{ "output", Encoding.UTF8.GetString(stream.ToArray()) }
});
HttpContent content = stream.AsContent();
content.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
// REVIEW: Why is it that we do not write an empty Content-Type here, like for InfoRefsController?
var response = new HttpResponseMessage();
response.Content = content;
response.WriteNoCache();
return response;
}
示例5: CreateResponse
private HttpResponseMessage CreateResponse(MemoryStream stream, string mediaType)
{
HttpContent content = null;
string flushStepTitle = String.Format("Creating content. L: {0}", stream.Length);
using (_profiler.Step(flushStepTitle))
{
content = new ByteArrayContent(stream.GetBuffer(), 0, (int)stream.Length);
}
content.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
// REVIEW: Why is it that we do not write an empty Content-Type here, like for InfoRefsController?
var response = new HttpResponseMessage();
response.Content = content;
response.WriteNoCache();
return response;
}
示例6: SmartInfoRefs
private HttpResponseMessage SmartInfoRefs(string service)
{
using (_profiler.Step("InfoRefsService.SmartInfoRefs"))
{
var memoryStream = new MemoryStream();
memoryStream.PktWrite("# service=git-{0}\n", service);
memoryStream.PktFlush();
if (service == "upload-pack")
{
_gitServer.Initialize();
_gitServer.AdvertiseUploadPack(memoryStream);
}
else if (service == "receive-pack")
{
_gitServer.Initialize();
_gitServer.AdvertiseReceivePack(memoryStream);
}
HttpContent content = null;
string flushStepTitle = String.Format("Creating content. L: {0}", memoryStream.Length);
using (_profiler.Step(flushStepTitle))
{
content = new ByteArrayContent(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
}
content.Headers.ContentType =
new MediaTypeHeaderValue("application/x-git-{0}-advertisement".With(service));
// Explicitly set the charset to empty string
// We do this as certain git clients (jgit) require it to be empty.
// If we don't set it, then it defaults to utf-8, which breaks jgit's logic for detecting smart http
content.Headers.ContentType.CharSet = "";
var responseMessage = new HttpResponseMessage();
responseMessage.Content = content;
responseMessage.WriteNoCache();
return responseMessage;
}
}
示例7: SmartInfoRefs
private HttpResponseMessage SmartInfoRefs(string service)
{
using (_tracer.Step("InfoRefsService.SmartInfoRefs"))
{
using (var memoryStream = new MemoryStream())
{
memoryStream.PktWrite("# service=git-{0}\n", service);
memoryStream.PktFlush();
if (service == "upload-pack")
{
_gitServer.AdvertiseUploadPack(memoryStream);
}
else if (service == "receive-pack")
{
_gitServer.AdvertiseReceivePack(memoryStream);
}
_tracer.Trace("Writing {0} bytes", memoryStream.Length);
HttpContent content = memoryStream.AsContent();
content.Headers.ContentType =
new MediaTypeHeaderValue("application/x-git-{0}-advertisement".With(service));
// Explicitly set the charset to empty string
// We do this as certain git clients (jgit) require it to be empty.
// If we don't set it, then it defaults to utf-8, which breaks jgit's logic for detecting smart http
content.Headers.ContentType.CharSet = "";
var responseMessage = new HttpResponseMessage();
responseMessage.Content = content;
responseMessage.WriteNoCache();
return responseMessage;
}
}
}