Giter VIP home page Giter VIP logo

persistent_httparty's People

Contributors

atorkhov avatar bmaland avatar josacar avatar pobocks avatar soupmatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

persistent_httparty's Issues

“:pool_size => 1” not use same connection

serv.rb

require "socket"
require 'time'
server = TCPServer.open("127.0.0.1", 80)

loop {
  Thread.start(server.accept) do |client| # new thread  if  connection  accepted
    puts "connected", client
    loop { #for established connection   loop gets/write forever 
      lines = []
      while line = client.gets and line !~ /^\s*$/
       lines << line.chomp
      end
      puts lines
      puts Thread.current
t = Time.now.utc
      echo = "Your conn is serve by thread %s" % Thread.current   # echo Thread.current to client
      headers = ["HTTP/1.0 200 OK",
                 "Server: ruby multi thread server",
                 'Connection: Keep-Alive',
                 "Content-Type: text/plain; charset=utf-8",
		 "Date: " << Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT"),
       		 "Age: 267230",
                 "Content-Length: #{echo.length}\r\n\r\n"].join("\r\n")
      puts "%d +  %d  = %d" % [headers.size , echo.size,headers.size + echo.size]
      client.write headers   #send to the client
      client.write echo
      # loop  client gets not close conn
    }
  end
}

client.rb

require "httparty"
require "persistent_httparty"

class Twitter
  include HTTParty
  persistent_connection_adapter :name => "my_cool_rest_client",
                                :pool_size => 1,
                                :idle_timeout => 10,
                                :keep_alive => 30
  base_uri "localhost"

  format :html  
  def self.query
    get("/")
  end
end

10.times do
  resp = Twitter.query
  resp.headers.each do |k, v|
    print k.capitalize, ": ", v, "\n"
  end
  puts 
  puts resp.body
  sleep 2
end

```
client recieve  different Thread.current ,that means:pool_size => 1not use same connection 

Proxy question

options = { http_proxyaddr: @proxy_addr, http_proxyport: @proxy_port, http_proxyuser: @proxy_user, http_proxypass: @proxy_pass }
get_response = HTTParty.get(url, options)

The proxy returns random ip whenever call.
But if I use this proxy in browser, it keeps same ip for 15 mins.
So I want to simulate that.
How can I keep connection open and send 2nd request with 1st request ip?
this gem will work for this?
Thanks

Broken links in README

Links to httparty and persistent_httparty are interpreted as relative links to files in project, rather than external links to web URLs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.