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


Python HTTPRequest.headers["If-Match"]方法代码示例

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


在下文中一共展示了HTTPRequest.headers["If-Match"]方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_agent_profile

# 需要导入模块: from tincan.http_request import HTTPRequest [as 别名]
# 或者: from tincan.http_request.HTTPRequest import headers["If-Match"] [as 别名]
    def save_agent_profile(self, profile):
        """Save an agent profile doc to the LRS

        :param profile: Agent profile doc to be saved
        :type profile: :class:`tincan.documents.agent_profile_document.AgentProfileDocument`
        :return: LRS Response object with the saved agent profile doc as content
        :rtype: :class:`tincan.lrs_response.LRSResponse`
        """
        request = HTTPRequest(
            method="PUT",
            resource="agents/profile",
            content=profile.content,
        )
        if profile.content_type is not None:
            request.headers["Content-Type"] = profile.content_type
        else:
            request.headers["Content-Type"] = "application/octet-stream"

        if profile.etag is not None:
            request.headers["If-Match"] = profile.etag

        request.query_params = {
            "profileId": profile.id,
            "agent": profile.agent.to_json(self.version)
        }
        lrs_response = self._send_request(request)
        lrs_response.content = profile

        return lrs_response
开发者ID:DamavandiKamali,项目名称:TinCanPython,代码行数:31,代码来源:remote_lrs.py

示例2: save_state

# 需要导入模块: from tincan.http_request import HTTPRequest [as 别名]
# 或者: from tincan.http_request.HTTPRequest import headers["If-Match"] [as 别名]
    def save_state(self, state):
        """Save a state doc to the LRS

        :param state: State document to be saved
        :type state: :class:`tincan.documents.state_document.StateDocument`
        :return: LRS Response object with saved state as content
        :rtype: :class:`tincan.lrs_response.LRSResponse`
        """
        request = HTTPRequest(
            method="PUT",
            resource="activities/state",
            content=state.content,
        )
        if state.content_type is not None:
            request.headers["Content-Type"] = state.content_type
        else:
            request.headers["Content-Type"] = "application/octet-stream"

        if state.etag is not None:
            request.headers["If-Match"] = state.etag

        request.query_params = {
            "stateId": state.id,
            "activityId": state.activity.id,
            "agent": state.agent.to_json(self.version)
        }
        lrs_response = self._send_request(request)
        lrs_response.content = state

        return self._send_request(request)
开发者ID:DamavandiKamali,项目名称:TinCanPython,代码行数:32,代码来源:remote_lrs.py

示例3: _delete_state

# 需要导入模块: from tincan.http_request import HTTPRequest [as 别名]
# 或者: from tincan.http_request.HTTPRequest import headers["If-Match"] [as 别名]
    def _delete_state(self, activity, agent, state_id=None, registration=None, etag=None):
        """Private method to delete a specified state from the LRS

        :param activity: Activity object of state to be deleted
        :type activity: :class:`tincan.activity.Activity`
        :param agent: Agent object of state to be deleted
        :type agent: :class:`tincan.agent.Agent`
        :param state_id: UUID of state to be deleted
        :type state_id: str | unicode
        :param registration: registration UUID of state to be deleted
        :type registration: str | unicode
        :param etag: etag of state to be deleted
        :type etag: str | unicode
        :return: LRS Response object with deleted state as content
        :rtype: :class:`tincan.lrs_response.LRSResponse`
        """
        if not isinstance(activity, Activity):
            activity = Activity(activity)

        if not isinstance(agent, Agent):
            agent = Agent(agent)

        request = HTTPRequest(
            method="DELETE",
            resource="activities/state"
        )

        if etag is not None:
            request.headers["If-Match"] = etag

        request.query_params = {
            "activityId": activity.id,
            "agent": agent.to_json(self.version)
        }
        if state_id is not None:
            request.query_params["stateId"] = state_id

        if registration is not None:
            request.query_params["registration"] = registration

        lrs_response = self._send_request(request)

        return lrs_response
开发者ID:DamavandiKamali,项目名称:TinCanPython,代码行数:45,代码来源:remote_lrs.py

示例4: delete_agent_profile

# 需要导入模块: from tincan.http_request import HTTPRequest [as 别名]
# 或者: from tincan.http_request.HTTPRequest import headers["If-Match"] [as 别名]
    def delete_agent_profile(self, profile):
        """Delete agent profile doc from LRS

        :param profile: Agent profile document to be deleted
        :type profile: :class:`tincan.documents.agent_profile_document.AgentProfileDocument`
        :return: LRS Response object
        :rtype: :class:`tincan.lrs_response.LRSResponse`
        """
        request = HTTPRequest(
            method="DELETE",
            resource="agents/profile"
        )
        request.query_params = {
            "profileId": profile.id,
            "agent": profile.agent.to_json(self.version)
        }

        if profile.etag is not None:
            request.headers["If-Match"] = profile.etag

        return self._send_request(request)
开发者ID:DamavandiKamali,项目名称:TinCanPython,代码行数:23,代码来源:remote_lrs.py


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