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


Python http.NO_CONTENT属性代码示例

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


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

示例1: render_POST

# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import NO_CONTENT [as 别名]
def render_POST(self, request):
        account_recovery = AccountRecovery(
            self._authenticator.bonafide_session,
            self.soledad(request),
            self._service(request, '_leap_session').smtp_config,
            self._get_backup_email(request),
            self._leap_provider.server_name,
            language=self._get_language(request))

        def update_response(response):
            request.setResponseCode(NO_CONTENT)
            request.finish()

        def error_response(response):
            request.setResponseCode(INTERNAL_SERVER_ERROR)
            request.finish()

        d = account_recovery.update_recovery_code()
        d.addCallbacks(update_response, error_response)
        return NOT_DONE_YET 
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:22,代码来源:backup_account_resource.py

示例2: write

# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import NO_CONTENT [as 别名]
def write(self, data):
        """
        Write data to the transport (if not responding to a HEAD request).

        @param data: A string to write to the response.
        @type data: L{bytes}
        """
        if not self.startedWriting:
            # Before doing the first write, check to see if a default
            # Content-Type header should be supplied. We omit it on
            # NOT_MODIFIED and NO_CONTENT responses. We also omit it if there
            # is a Content-Length header set to 0, as empty bodies don't need
            # a content-type.
            needsCT = self.code not in (http.NOT_MODIFIED, http.NO_CONTENT)
            contentType = self.responseHeaders.getRawHeaders(b'content-type')
            contentLength = self.responseHeaders.getRawHeaders(
                b'content-length'
            )
            contentLengthZero = contentLength and (contentLength[0] == b'0')

            if (needsCT and contentType is None and
                self.defaultContentType is not None and
                not contentLengthZero
                    ):
                self.responseHeaders.setRawHeaders(
                    b'content-type', [self.defaultContentType])

        # Only let the write happen if we're not generating a HEAD response by
        # faking out the request method.  Note, if we are doing that,
        # startedWriting will never be true, and the above logic may run
        # multiple times.  It will only actually change the responseHeaders
        # once though, so it's still okay.
        if not self._inFakeHead:
            if self._encoder:
                data = self._encoder.encode(data)
            http.Request.write(self, data) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:38,代码来源:server.py

示例3: render

# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import NO_CONTENT [as 别名]
def render(self, request):
        request.setResponseCode(http.NO_CONTENT)
        return b'' 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:5,代码来源:test_web.py

示例4: test_deleteEvent

# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import NO_CONTENT [as 别名]
def test_deleteEvent(self):
        """
        L{OS_X_10_11.deleteEvent} DELETEs the event at the relative
        URL passed to it and updates local state to reflect its
        removal.
        """
        requests = self.interceptRequests()

        calendar = Calendar(caldavxml.calendar, set(('VEVENT',)), u'calendar', u'/foo/', None)
        event = Event(None, calendar.url + u'bar.ics', None)
        self.client._calendars[calendar.url] = calendar
        self.client._setEvent(event.url, event)

        d = self.client.deleteEvent(event.url)

        result, req = requests.pop()

        expectedResponseCode, method, url = req

        self.assertEqual(expectedResponseCode, (NO_CONTENT, NOT_FOUND))
        self.assertEqual(method, 'DELETE')
        self.assertEqual(url, 'http://127.0.0.1' + event.url)
        self.assertIsInstance(url, str)

        self.assertNotIn(event.url, self.client._events)
        self.assertNotIn(u'bar.ics', calendar.events)

        response = MemoryResponse(
            ('HTTP', '1', '1'), NO_CONTENT, "No Content", None,
            StringProducer(""))
        result.callback((response, ""))
        return d 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:34,代码来源:test_ical.py

示例5: deleteResource

# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import NO_CONTENT [as 别名]
def deleteResource(self, path):
        url = self._makeURL(path)
        d = self.agent.request('DELETE', url)

        def deleted(response):
            if response.code not in (NO_CONTENT, NOT_FOUND):
                raise Exception(
                    "Unexpected response to DELETE %s: %d" % (
                        url, response.code))
        d.addCallback(deleted)
        return d 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:13,代码来源:benchlib.py


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