当前位置: 首页>>代码示例>>C#>>正文


C# IHttpResponse.AppendHeader方法代码示例

本文整理汇总了C#中IHttpResponse.AppendHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpResponse.AppendHeader方法的具体用法?C# IHttpResponse.AppendHeader怎么用?C# IHttpResponse.AppendHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHttpResponse的用法示例。


在下文中一共展示了IHttpResponse.AppendHeader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteHeaders

        public static void WriteHeaders(IHttpResponse response, IFubuFile file)
        {
            var mimeType = MimeType.MimeTypeByFileName(file.Path);
            if (mimeType != null)
            {
                response.AppendHeader(HttpResponseHeaders.ContentType, mimeType.Value);
            }

            response.AppendHeader(HttpResponseHeaders.LastModified, file.LastModified().ToString("r"));
            response.AppendHeader(HttpResponseHeaders.ETag, file.Etag().Quoted());

        }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:12,代码来源:WriteFileHeadContinuation.cs

示例2: Write

        public override void Write(IHttpResponse response)
        {
            response.WriteFile(_file.Path);

            WriteFileHeadContinuation.WriteHeaders(response, _file);

            _settings.Headers.Each((key, source) => response.AppendHeader(key, source()));

            response.WriteResponseCode(HttpStatusCode.OK);
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:10,代码来源:WriteFileContinuation.cs

示例3: Write

        public override void Write(IHttpResponse response)
        {
            WriteHeaders(response, _file);

            if (_status == HttpStatusCode.OK)
            {
                response.AppendHeader(HttpResponseHeaders.ContentLength, _file.Length().ToString());
            }

            response.WriteResponseCode(_status);
        }
开发者ID:cothienlac86,项目名称:fubumvc,代码行数:11,代码来源:WriteFileHeadContinuation.cs

示例4: GetHttpResponse

        /// <summary>
        /// Sets the parameters of the incoming http response from a CoAP response.
	    /// The status code is mapped through the properties file and is set through
	    /// the StatusLine. The options are translated to the corresponding headers
	    /// and the max-age (in the header cache-control) is set to the default value
	    /// (60 seconds) if not already present. If the request method was not HEAD
	    /// and the coap response has a payload, the entity and the content-type are
        /// set in the http response.
        /// </summary>
        public static void GetHttpResponse(IHttpRequest httpRequest, Response coapResponse, IHttpResponse httpResponse)
        {
            if (httpRequest == null)
                throw ThrowHelper.ArgumentNull("httpRequest");
            if (coapResponse == null)
                throw ThrowHelper.ArgumentNull("coapResponse");
            if (httpResponse == null)
                throw ThrowHelper.ArgumentNull("httpResponse");

            HttpStatusCode httpCode;

            if (!coap2httpCode.TryGetValue(coapResponse.StatusCode, out httpCode))
                throw ThrowHelper.TranslationException("Cannot convert the coap code in http status code: " + coapResponse.StatusCode);

            httpResponse.StatusCode = (Int32)httpCode;

            NameValueCollection nvc = GetHttpHeaders(coapResponse.GetOptions());
            // set max-age if not already set
            if (nvc["cache-control"] == null)
                nvc.Set("cache-control", "max-age=" + CoapConstants.DefaultMaxAge);

            foreach (String key in nvc.Keys)
            {
                httpResponse.AppendHeader(key, nvc[key]);
            }

            Byte[] payload = coapResponse.Payload;
            if (payload != null)
            {
                httpResponse.OutputStream.Write(payload, 0, payload.Length);
                String contentType;
                if (coap2httpContentType.TryGetValue(coapResponse.ContentType, out contentType))
                    httpResponse.AppendHeader("content-type", contentType);
            }
        }
开发者ID:vjine,项目名称:CoAP.NET,代码行数:44,代码来源:HttpTranslator.cs

示例5: Write

 public void Write(IHttpResponse response)
 {
     response.AppendHeader(_name, _value);
 }
开发者ID:staticage,项目名称:radish,代码行数:4,代码来源:HeaderResponseWriter.cs

示例6: Replay

 public Task Replay(IHttpResponse response)
 {
     response.AppendHeader(Name, Value);
     return Task.CompletedTask;
 }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:5,代码来源:Header.cs

示例7: Replay

 public void Replay(IHttpResponse response)
 {
     response.AppendHeader(Name, Value);
 }
开发者ID:cothienlac86,项目名称:fubumvc,代码行数:4,代码来源:Header.cs


注:本文中的IHttpResponse.AppendHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。