Replaces the current user agent in the requests session headers.
483549
def set_user_agent(self, user_agent):
        """"""
        # set a default user_agent if not specified
        if user_agent is None:
            requests_ua = requests.utils.default_user_agent()
            user_agent = '%s (%s/%s)' % (requests_ua, __title__, __version__)

        # the requests module uses a case-insensitive dict for session headers
        self.session.headers['User-agent'] = user_agent
352228
def request(self, method, path, **options):
        
        options = self._update_user_agent_header(options)

        url = "{}{}".format(self.base_url, path)

        response = getattr(self.session, method)(url, auth=self.auth,
                                                 verify=self.cert_path,
                                                 **options)
        if ((response.status_code >= HTTP_STATUS_CODE.OK) and
                (response.status_code < HTTP_STATUS_CODE.REDIRECT)):
            return response.json()
        else:
            msg = ""
            code = ""
            json_response = response.json()
            if 'error' in json_response:
                if 'description' in json_response['error']:
                    msg = json_response['error']['description']
                if 'code' in json_response['error']:
                    code = str(json_response['error']['code'])

            if str.upper(code) == ERROR_CODE.BAD_REQUEST_ERROR:
                raise BadRequestError(msg)
            elif str.upper(code) == ERROR_CODE.GATEWAY_ERROR:
                raise GatewayError(msg)
            elif str.upper(code) == ERROR_CODE.SERVER_ERROR:
                raise ServerError(msg)
            else:
                raise ServerError(msg)
1104861
def reset
      self.adapter     = DEFAULT_ADAPTER
      self.token       = DEFAULT_TOKEN
      self.endpoint    = DEFAULT_ENDPOINT
      self.user_agent  = DEFAULT_USER_AGENT
      self.proxy       = DEFAULT_PROXY
      self.ca_path     = DEFAULT_CA_PATH
      self.ca_file     = DEFAULT_CA_FILE
      self.middlewares = DEFAULT_MIDDLEWARES
    end
123769
function replaceAssociation(req, res) {
  if(redirect(req.params.id, '', '', res)) {
    return;
  }

  var id = req.params.id;
  var url = req.body.url;
  var directory = req.body.directory;
  var tags = req.body.tags;
  var position = req.body.position;
  var rootUrl = req.protocol + '://' + req.get('host');
  var queryPath = req.originalUrl;
  req.chickadee.setAssociation(req, id, url, directory, tags, position,
                               rootUrl, queryPath, function(response, status) {
    res.status(status).json(response);
  });
}
369036
def user_agent(style=None) -> _UserAgent:
    
    global useragent
    if (not useragent) and style:
        useragent = UserAgent()

    return useragent[style] if style else DEFAULT_USER_AGENT
726068
public void updateUser(User user){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.UpdateUser);

        UpdateUserProtocol p = new UpdateUserProtocol(user);

        connection.submitRequest(header, p, null);
    }
814593
private void modify(Set<Permission> permissions, IResource resource, String user, String op) throws RequestExecutionException
    {
        process(String.format("UPDATE %s.%s SET permissions = permissions %s {%s} WHERE username = '%s' AND resource = '%s'",
                              Auth.AUTH_KS,
                              PERMISSIONS_CF,
                              op,
                              "'" + StringUtils.join(permissions, "','") + "'",
                              escape(user),
                              escape(resource.getName())));
    }
329837
def get_new_session(self):
        """"""
        session = Session()
        session.headers = self.headers
        session.proxies = self._get_request_proxies()
        return session
1336129
def update_user(self, user, username=None, first_name=None, last_name=None):
		""""""
		
		if not isinstance(user, User):
			raise ValueError
		args = locals()
		url = api_url+'users/'+str(user.id)+'/'
		payload = {}
		for i in args:
			if args[i] is not None and i not in ['self', 'user']:
				payload[i] = args[i]
		r = requests.patch(url, data=json.dumps(payload), headers=self.headers)
		print(request_status(r))
		r.raise_for_status()
		return User(r.json())
900930
def replace_header(self, _name, _value):
        
        _name = _name.lower()
        for i, (k, v) in zip(range(len(self._headers)), self._headers):
            if k.lower() == _name:
                self._headers[i] = self.policy.header_store_parse(k, _value)
                break
        else:
            raise KeyError(_name)
973259
def update_current_user(self, **params):
        """"""
        response = self._put('v2', 'user', data=params)
        return self._make_api_object(response, CurrentUser)
1214415
def request(method, url, headers=None, data=None, session=None):
    
    base_headers = {
        'User-Agent': random_agent()
    }
    if headers is None:
        headers = {}

    base_headers.update(headers)

    if 'Content-Length' in headers:
        del base_headers['Content-Length']

    headers = base_headers
    if session is not None:
        req = session.request
    else:
        req = requests.request

    r = req(method, url, headers=headers, data=data)
    return r
138542
def get_session(user_agent):
    """"""

    client = requests.Session()
    client.headers.update({
        'Content-Type': 'application/json',
        'User-Agent': user_agent,
    })
    retry = Retry(connect=3, backoff_factor=3)
    adapter = HTTPAdapter(max_retries=retry)
    client.mount('https://', adapter)
    return client
879676
def remove_user(user):
    """"""
    def processor(action, argument):
        ActionUsers.query_by_action(action, argument=argument).filter(
            ActionUsers.user_id == user.id
        ).delete(synchronize_session=False)
    return processor
580634
private void applyUserAgent(PutMediaRequest request, Request<PutMediaRequest> marshalled) {
        if (!marshalled.getHeaders().containsKey("User-Agent")) {
            marshalled.addHeader("User-Agent",
                                 RuntimeHttpUtils.getUserAgent(new ClientConfiguration(),
                                                               request.getRequestClientOptions()
                                                                      .getClientMarker(RequestClientOptions.Marker.USER_AGENT)));
        }
    }
1169643
def changeUserAuthorizations(self, login, user, authorizations):
    
    self.send_changeUserAuthorizations(login, user, authorizations)
    self.recv_changeUserAuthorizations()
767795
def new_request_session(config, cookies):
    """"""
    session = requests.Session()
    if cookies:
        session.cookies = cookies
    session.max_redirects = config["maxhttpredirects"]
    session.headers.update({
        "User-Agent": config["useragent"],
    })
    if config["cookiefile"]:
        for cookie in cookies.from_file(config["cookiefile"]):
            session.cookies = requests.cookies.merge_cookies(session.cookies, cookie)
    return session