Send a request to the DNS server
2030
def send_request
      nameserver = @nameservers.shift
      @nameservers << nameserver # rotate them
      begin
        @socket.send request_message, 0, @nameservers.first, DNS_PORT
      rescue Errno::EHOSTUNREACH # TODO figure out why it has to be wrapper here, when the other wrapper should be wrapping this one!
      end
    end
1301232
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT):
        """"""
        # This is a quick test to see if we can parse the packets we generate
        #temp = DNSIncoming(out.packet())
        for i in self.intf.values():
            try:
                return i.sendto(out.packet(), 0, (addr, port))
            except:
                traceback.print_exc()
                # Ignore this, it may be a temporary loss of network connection
                return -1
922758
def send_request(request)
      begin
        uri = URI "#{request.gateway_url}/#{request.api_method}/#{request.end_point}"

        response = HTTP.start uri.hostname, uri.port, :use_ssl => uri.scheme == 'https' do |http|
          post = HTTP::Post.new uri.request_uri
          post.set_form_data request.request_fields
          http.request post
        end
      rescue Exception => e
        raise RequestError, "Error occurred. #{e.message}"
      end

      unless HTTPOK === response
        raise RequestError, "Error occurred. HTTP code: '#{response.code}'. Server message: '#{response.message}'"
      end

      response
    end
1151746
def send(self, request):
        ''''''
        return self.session.send(request(self.url, self.auth))
955252
def request_server_info(self):
        ''' 

        '''
        if self._server_info is None:
            self._server_info = self._send_request_server_info()
        return self._server_info
1230005
def sendrequest(self, request):
        '''
            
        '''
        url = urlparse.urlparse(self.connection.healthserviceurl)
        conn = None
        if url.scheme == 'https':
            conn = httplib.HTTPSConnection(url.netloc)
        else:
            conn = httplib.HTTPConnection(url.netloc)
        conn.putrequest('POST', url.path)
        conn.putheader('Content-Type', 'text/xml')
        conn.putheader('Content-Length', '%d' % len(request))
        conn.endheaders()
        try:
            conn.send(request)
        except socket.error, v:
            if v[0] == 32:      # Broken pipe
                conn.close()
            raise
        response = conn.getresponse().read()
        return etree.fromstring(response)
220266
def send_http_request
      net_http_options = [uri.host, uri.port, use_ssl: true]
      ActiveSupport::Notifications.instrument 'request.yt' do |payload|
        payload[:method] = @method
        payload[:request_uri] = uri
        payload[:response] = Net::HTTP.start(*net_http_options) do |http|
          http.request http_request
        end
      end
    end
604877
public function sendRequest()
  {
    // Prepare LinkFinder
    $this->LinkFinder->resetLinkCache();
    $this->LinkFinder->setSourceUrl($this->UrlDescriptor);
    
    // Initiate the Response-object and pass base-infos
    $PageInfo = new PHPCrawlerDocumentInfo();
    $PageInfo->url = $this->UrlDescriptor->url_rebuild;
    $PageInfo->protocol = $this->url_parts["protocol"];
    $PageInfo->host = $this->url_parts["host"];
    $PageInfo->path = $this->url_parts["path"];
    $PageInfo->file = $this->url_parts["file"];
    $PageInfo->query = $this->url_parts["query"];
    $PageInfo->port = $this->url_parts["port"];
    $PageInfo->url_link_depth = $this->UrlDescriptor->url_link_depth;
    
    // Create header to send
    $request_header_lines = $this->buildRequestHeader();
    $header_string = trim(implode("", $request_header_lines));
    $PageInfo->header_send = $header_string;
    
    // Open socket
    $this->openSocket($PageInfo->error_code, $PageInfo->error_string);
    $PageInfo->server_connect_time = $this->server_connect_time;
    
    // If error occured
    if ($PageInfo->error_code != null)
    {
      // If proxy-error -> throw exception
      if ($PageInfo->error_code == PHPCrawlerRequestErrors::ERROR_PROXY_UNREACHABLE)
      {
        throw new Exception("Unable to connect to proxy '".$this->proxy["proxy_host"]."' on port '".$this->proxy["proxy_port"]."'");
      }
      
      $PageInfo->error_occured = true;
      return $PageInfo; 
    }
    
    // Send request
    $this->sendRequestHeader($request_header_lines);
    
    // Read response-header
    $response_header = $this->readResponseHeader($PageInfo->error_code, $PageInfo->error_string);
    $PageInfo->server_response_time = $this->server_response_time;
    
    // If error occured
    if ($PageInfo->error_code != null)
    {
      $PageInfo->error_occured = true;
      return $PageInfo; 
    }
    
    // Set header-infos
    $this->lastResponseHeader = new PHPCrawlerResponseHeader($response_header, $this->UrlDescriptor->url_rebuild);
    $PageInfo->responseHeader = $this->lastResponseHeader;
    $PageInfo->header = $this->lastResponseHeader->header_raw;
    $PageInfo->http_status_code = $this->lastResponseHeader->http_status_code;
    $PageInfo->content_type = $this->lastResponseHeader->content_type;
    $PageInfo->cookies = $this->lastResponseHeader->cookies;
    
    // Referer-Infos
    if ($this->UrlDescriptor->refering_url != null)
    {
      $PageInfo->referer_url = $this->UrlDescriptor->refering_url;
      $PageInfo->refering_linkcode = $this->UrlDescriptor->linkcode;
      $PageInfo->refering_link_raw = $this->UrlDescriptor->link_raw;
      $PageInfo->refering_linktext = $this->UrlDescriptor->linktext;
    }
    
    // Check if content should be received
    $receive = $this->decideRecevieContent($this->lastResponseHeader);
    
    if ($receive == false)
    {
      @fclose($this->socket);
      $PageInfo->received = false;
      $PageInfo->links_found_url_descriptors = $this->LinkFinder->getAllURLs(); // Maybe found a link/redirect in the header
      $PageInfo->meta_attributes = $this->LinkFinder->getAllMetaAttributes();
      return $PageInfo;
    }
    else
    {
      $PageInfo->received = true;
    }
    
    // Check if content should be streamd to file
    $stream_to_file = $this->decideStreamToFile($response_header);
                    
    // Read content
    $response_content = $this->readResponseContent($stream_to_file, $PageInfo->error_code, $PageInfo->error_string, $PageInfo->received_completely);
     
    // If error occured
    if ($PageInfo->error_code != null)
    {
      $PageInfo->error_occured = true;
    }
    
    @fclose($this->socket);
    
    // Complete ResponseObject
    $PageInfo->content = $response_content;
    $PageInfo->source = &$PageInfo->content;
    $PageInfo->received_completly = $PageInfo->received_completely;
    
    if ($stream_to_file == true)
    {
      $PageInfo->received_to_file = true;
      $PageInfo->content_tmp_file = $this->tmpFile;
    }
    else $PageInfo->received_to_memory = true;
    
    $PageInfo->links_found_url_descriptors = $this->LinkFinder->getAllURLs();
    $PageInfo->meta_attributes = $this->LinkFinder->getAllMetaAttributes();
    
    // Info about received bytes
    $PageInfo->bytes_received = $this->content_bytes_received;
    $PageInfo->header_bytes_received = $this->header_bytes_received;
    
    $dtr_values = $this->calulateDataTransferRateValues();
    if ($dtr_values != null)
    {
      $PageInfo->data_transfer_rate = $dtr_values["data_transfer_rate"];
      $PageInfo->unbuffered_bytes_read = $dtr_values["unbuffered_bytes_read"];
      $PageInfo->data_transfer_time = $dtr_values["data_transfer_time"];
    }
    
    $PageInfo->setLinksFoundArray();
    
    $this->LinkFinder->resetLinkCache();
    
    return $PageInfo;
  }
1185223
def send_request(host_name, request):
    
    request = "%s%s" % (host_name, request)
    # print(request)
    try:
        result = requests.get(request)
        if result.status_code == 200:
            return result
        else:
            # print(result.status_code)
            raise Exception
    except Exception as e:
        # print(e)
        raise e
504236
def _send_query(self):
        
        timeout = 60
        ofproto = self._datapath.ofproto
        parser = self._datapath.ofproto_parser
        if ofproto_v1_0.OFP_VERSION == ofproto.OFP_VERSION:
            send_port = ofproto.OFPP_NONE
        else:
            send_port = ofproto.OFPP_ANY

        # create a general query.
        res_igmp = igmp.igmp(
            msgtype=igmp.IGMP_TYPE_QUERY,
            maxresp=igmp.QUERY_RESPONSE_INTERVAL * 10,
            csum=0,
            address='0.0.0.0')
        res_ipv4 = ipv4.ipv4(
            total_length=len(ipv4.ipv4()) + len(res_igmp),
            proto=inet.IPPROTO_IGMP, ttl=1,
            src='0.0.0.0',
            dst=igmp.MULTICAST_IP_ALL_HOST)
        res_ether = ethernet.ethernet(
            dst=igmp.MULTICAST_MAC_ALL_HOST,
            src=self._datapath.ports[ofproto.OFPP_LOCAL].hw_addr,
            ethertype=ether.ETH_TYPE_IP)
        res_pkt = packet.Packet()
        res_pkt.add_protocol(res_ether)
        res_pkt.add_protocol(res_ipv4)
        res_pkt.add_protocol(res_igmp)
        res_pkt.serialize()

        flood = [parser.OFPActionOutput(ofproto.OFPP_FLOOD)]

        while True:
            # reset reply status.
            for status in self._mcast.values():
                for port in status.keys():
                    status[port] = False

            # send a general query to the host that sent this message.
            self._do_packet_out(
                self._datapath, res_pkt.data, send_port, flood)
            hub.sleep(igmp.QUERY_RESPONSE_INTERVAL)

            # QUERY timeout expired.
            del_groups = []
            for group, status in self._mcast.items():
                del_ports = []
                actions = []
                for port in status.keys():
                    if not status[port]:
                        del_ports.append(port)
                    else:
                        actions.append(parser.OFPActionOutput(port))
                if len(actions) and len(del_ports):
                    self._set_flow_entry(
                        self._datapath, actions, self.server_port, group)
                if not len(actions):
                    self._del_flow_entry(
                        self._datapath, self.server_port, group)
                    del_groups.append(group)
                if len(del_ports):
                    for port in del_ports:
                        self._del_flow_entry(self._datapath, port, group)
                for port in del_ports:
                    del status[port]
            for group in del_groups:
                del self._mcast[group]

            rest_time = timeout - igmp.QUERY_RESPONSE_INTERVAL
            hub.sleep(rest_time)
841878
def ping(self, handler='admin/ping', **kwargs):
        
        params = kwargs
        params_encoded = safe_urlencode(params, True)

        if len(params_encoded) < 1024:
            # Typical case.
            path = '%s/?%s' % (handler, params_encoded)
            return self._send_request('get', path)
        else:
            # Handles very long queries by submitting as a POST.
            path = '%s/' % handler
            headers = {
                'Content-type': 'application/x-www-form-urlencoded; charset=utf-8',
            }
            return self._send_request('post', path, body=params_encoded, headers=headers)
1229771
def run(self):
        

        logging.debug("Querying server {0}".format(self.server['ip']))

        try:
            # Create a DNS resolver query
            rsvr = dns.resolver.Resolver()
            rsvr.nameservers = [self.server['ip']]
            rsvr.lifetime = 5
            rsvr.timeout = 5

            qry = rsvr.query(self.domain, self.recType)

            # Get the results, sort for consistancy
            results = sorted([r.to_text() for r in qry])
            success = True
        # Handle all the various exceptions
        except dns.resolver.NXDOMAIN:
            success = False
            results = ['NXDOMAIN']
        except dns.resolver.NoNameservers:
            success = False
            results = ['No Nameservers']
        except dns.resolver.NoAnswer:
            success = False
            results = ['No Answer']
        except dns.resolver.Timeout:
            success = False
            results = ['Server Timeout']

        # Save the results
        self.result = {
            'server': self.server,
            'results': results,
            'success': success
        }
358790
def _send_request(self, request, **kwargs):
        """"""
        log.debug(LOG_CHECK, "Send request %s with %s", request, kwargs)
        log.debug(LOG_CHECK, "Request headers %s", request.headers)
        self.url_connection = self.session.send(request, **kwargs)
        self.headers = self.url_connection.headers
        self._add_ssl_info()
61344
def request(self, method, url, body=None, headers={}):
        """"""
        self._send_request(method, url, body, headers)
176934
def _request(self, request, proxies, timeout, verify, **_):
        

        settings = self.http.merge_environment_settings(
            request.url, proxies, False, verify, None)

        self._delay()
        response = self.http.send(
            request, timeout=timeout, allow_redirects=False, **settings)
        self._update(response.headers)

        return response
1373543
def _send_queries(self):
        

        res = 0

        addrs = _resolve_addrs(self.addresses, self.port, self.ignore_senderrors, [self._sock.family])
        for addr in addrs:
            try:
                self._send_query(addr[1])
                res += 1
            except:
                if not self.ignore_senderrors:
                    raise

        return res
1316133
def send_request(self, method, url, headers=None,
                     data=None, is_retry=False):
        """"""
        if not self._token:
            self.login()

        if not headers:
            headers = {}

        headers['Authorization'] = 'Bearer ' + self._oauth_token
        headers['ABODE-API-KEY'] = self._token

        try:
            response = getattr(self._session, method)(
                url, headers=headers, json=data)

            if response and response.status_code < 400:
                return response
        except RequestException:
            _LOGGER.info("Abode connection reset...")

        if not is_retry:
            # Delete our current token and try again -- will force a login
            # attempt.
            self._token = None

            return self.send_request(method, url, headers, data, True)

        raise AbodeException((ERROR.REQUEST))