w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to limit download rate of HTTP requests in requests python library?
There are several approaches to rate limiting; one of them is token bucket, for which you can find a recipe here and another one here. Usually you would want to do throttling or rate limiting on socket.send() and socket.recv(). You could play with socket-throttle and see if it does what you need. This is not to be confused with x-ratelimit rate limiting response headers, which are related to a number of requests rather than a download / transfer rate.

Categories : Python

How python-wsgi manage http requests?
Some bed time read/watching for you: http://blog.dscpl.com.au/2009/03/python-interpreter-is-not-created-for.html http://lanyrd.com/2013/pycon/scdyzk/ http://lanyrd.com/2012/pycon/spcdg/ The document you already referred to should explain a lot about the process/thread model already.

Categories : Python

Keeping state between HTTP requests with python's BaseHTTPRequestHandler
You can use the multiprocessing module to accomplish this. First derive a server class: class MyTCPServer(SocketServer.ForkingTCPServer): manager = multiprocessing.Manager() SHARED = manager.dict() Then in your handler's do_GET you can do something like: self.server.SHARED['foo'] = 1 Which should then be referable by other instance of do_GET.

Categories : Python

python, send many HTTP requests through one network connection
The fact that both solutions shared some code like Lukasa said, and the fact that both results were equivalent whenever querying Apache or Tomcat made me first think it was related to the Python code. But in fact it was related to the servers configurations. The trick is that both Apache and Tomcat share a setting which indicates how many HTTP requests can be made within the same TCP connection. And both have a default value of 100. Tomcat: maxKeepAliveRequests: The maximum number of HTTP requests which can be pipelined until the connection is closed by the server. If not specified, this attribute is set to 100. See http://tomcat.apache.org/tomcat-7.0-doc/config/http.html#Standard_Implementation Apache: MaxKeepAliveRequests: The MaxKeepAliveRequests directive limits th

Categories : Python

python http server, multiple simultaneous requests
I had same problem, but no tornado, no mysql. Do you have one database connection shared with all server? I created a multiprocessing.Pool. Each have its own db connection provided by init function. I wrap slow code in function and map it to Pool. So i have no shared variables and connections. Sleep not blocks other threads, but DB transaction may block threads. You need to setup Pool at top of your code. def spawn_pool(fishes=None): global pool from multiprocessing import Pool def init(): from storage import db #private connections db.connect() #connections stored in db-framework and will be global in each process pool = Pool(processes=fishes,initializer=init) if __name__ == "__main__": spawn_pool(8) from storage import db #shared connection for

Categories : Python

duplicate HTTP POST from python script with Lua
Make sure your Lua script is sending the same HTTP headers. The important part for PHP is that the form with attached file upload is sent as "multipart/form-data", and the file must be properly embedded in the POST body of the HTTP request as a multipart mime message. I cannot see if your Lua script actually does this, but I think no. Otherwise PHP would be happy.

Categories : PHP

Sometimes Python Requests module and wget HTTP responses contradicts curl/Chrome
You're sending a HEAD request with requests rather than a GET. Try requests.get("http://www.dagoradiosound.info/site/") instead. Using curl -I "http://www.dagoradiosound.info/site/" to fetch the headers only will also return a 404 status for this particular URL.

Categories : Http

How to make asynchronous HTTP GET requests in Python and pass response object to a function
I tried your code and could get it work by adding an additional parameter kwargs to your print_url function. def print_url(r, **kwargs): print r.url I figured what was wrong in this other stackoverlow question: Problems with hooks using Requests Python package. It seems when you use the response hook in grequests you need to add **kwargs in your callback definition.

Categories : Python

Python script that simultaneously listens/responds to HTTP requests, serial port, and time-based events?
It seems like you are trying to write an asynchronous application to manage your network of nodes via HTTP. You want to respond to incoming communications on multiple channels as they occur, you want to initiate communications on a schedule, on multiple channels, and you want those two forms of communication to interact. All of these communications are with an outside world that is slow, so it behooves you not to block if you don't need to. It will probably be easiest to maintain your system if you organize your code into several Python modules, split by their area of concern - serial interface code, HTTP interface code, common processing code-paths, etc. Weave those components together in a central control module, which imports your libraries, and knows how to start and stop cleanly.

Categories : Python

How to redirect all HTTPS requests to HTTP requests?
In the Global.asax file try something like. protected void Application_BeginRequest() { if (Context.Request.IsSecureConnection) Response.Redirect(Context.Request.Url.ToString().Replace("https:", "http:")); }

Categories : Asp Net Mvc

python-requests returning unicode Exception message (or how to set requests locale)
You can try os.strerror, but it would probably return nothing or the same non-English string. This hard-coded English was scraped from here: http://support.microsoft.com/kb/819124 ENGLISH_WINDOWS_SOCKET_MESSAGES = { 10004: "Interrupted function call.", 10013: "Permission denied.", 10014: "Bad address.", 10022: "Invalid argument.", 10024: "Too many open files.", 10035: "Resource temporarily unavailable.", 10036: "Operation now in progress.", 10037: "Operation already in progress.", 10038: "Socket operation on nonsocket.", 10039: "Destination address required.", 10040: "Message too long.", 10041: "Protocol wrong type for socket.", 10042: "Bad protocol option.", 10043: "Protocol not supported.", 10044: "Socket type not supported.",

Categories : Python

Consecutive requests with python Requests.Session() not working
In the lastest version of requests, he sessions object is with Cookie Persistence, look the requests Sessions ojbects docs. So you don't need add the cookie artificialy. Just import requests s=requests.Session() login_data = dict(userName='user', password='pwd') ra=s.post('http://example/checklogin.php', data=login_data) print ra.content print ra.headers ans = dict(answer='5') r=s.post('http://example/level1.php',data=ans) print r.content Just print the cookie to look up wheather you were logged. for cookie in s.cookies: print (cookie.name, cookie.value) And is the example site is yours? If not maybe the site reject the bot/crawler ! And you can change your requests's user-agent as looks likes you are using a browser. For example: import requests s=requests.Session() headers

Categories : Python

Get and set HTTP requests
Are you looking for something like a browser extension? For example, Tamper Data for Firefox can be used to block every HTTP requests for viewing and modifying before they are sent.

Categories : Javascript

How to get Android HTTP requests?
If you are rooted, you can get a Wireshark port for Android here. You can record all network traffic on your phone, take the tcpdump files, and read them with a desktop version of Wireshark. You can also use the android emulator on computers. Start the emulator via command line and add the -tcpdump tag. Use adb push my_app.apk to install your application onto the device. This will save a tcpdump file onto your PC, which can also be read with Wireshark. For live tracking, you can also proxy your android connections through something like burp proxy.

Categories : Android

Why don't I need to specify a CA bundle to Net::HTTP SSL requests?
It looks like if no verify callback is set then OpenSSL library default callback is used. See line 217 in the openssl module verify callback wrapper (the ok argument is the result of the default callback). On OS X, Apple has apparently customized the default callback in their OpenSSL library to hook in to the OS X Keychain facility. The root CA of Google's certificate is Equifax Secure Certificate Authority. If you change the trust setting in Keychain (e.g. using the Keychain Access utility) for this CA then your ruby test behaves accordingly. I believe the answer to your question is that when peer certificate verification is required but not configured, the ruby shipped with OS X verifies using Keychain.

Categories : Ruby

Proxy with HTTP Requests
I was able to add a proxy to HttpClient, HttpWebRequest and HttpRequestMessage. They do not have to be used together, but I just found two ways of making HTTP Requests with proxy. To do this in windows store/metro applications, you would have to implement IWebProxy. Take a look at this for implementing IWebProxy: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/6e20c2c0-105c-4d66-8535-3ddb9a048b69/bug-missing-type-webproxy-cant-set-proxy-then-where-is-the-appconfig Then all you need to do is set the proxy for HttpClient or HttpWebRequest: HttpClient: HttpClientHandler aHandler = new HttpClientHandler(); IWebProxy proxy = new MyProxy(new Uri("http://xx.xx.xx.xxx:xxxx")); proxy.Credentials = new NetworkCredential("xxxx", "xxxx"); aHandler.Proxy = proxy; HttpClient client = new

Categories : C#

ASP.NET and incomplete HTTP requests
For what I know any limit imposed by IIS can be easily reached with hacking "Slow HTTP Post" Denial os Service (DoS) attack. the hacker creates multiple instance of the service sending small incomplete requests (without .RequestBody CRL termination). This kind of attack left open the link that is waiting the incomplete part. If a bot does this, it never will send the remaining part, exceeding the limit returning "Deny of Service". Probabily your uploaded file is 0 bytes because the site could be under attack and can't complete the request. In any case to prevent DoS attack need to check programmatically the incomplete requests and kill them take a look here http://omaralzabir.com/prevent_denial_of_service__dos__attacks_in_your_web_application/

Categories : Asp Net

AngularJS intercept all $http requests
The request interceptor isn't running after the data is returned. It's running before. Your logIt function inserts the newest message at the top. If you change your code to use the $log service, you'll see that the interceptor runs first.

Categories : Angularjs

How to capture all HTTP requests from certain processes?
WinPCap allows you to access the source and destination IP/Port pairs for each captured packet. You can iterate the OS's TCP tables (on Windows, you can use GetTcpTable2() and GetTcp6Table2()) looking for those pairs, and when you find a match then you will know the process ID that owns that connection. From that ID, you can then extract further information about that process from the OS (filename, etc).

Categories : C++

How can I Make fewer HTTP requests?
What are CSS Sprites? An image sprite is a collection of images put into a single image. A web page with many images can take a long time to load and generates multiple server requests. Using image sprites will reduce the number of server requests and save bandwidth. To make sprites check this online service For your javascript and css problems. What you need is a compressor. If you really want to follow the instructions that is. Here is a sample of a css/javascript compressor (there are alternatives to this a quick google will help) But I personally have problems when putting all scripts in to just one file. Just remember that it would be better that you just simply add external scripts that the page will actually need. AND May I suggest using a cdn to help speed up servin

Categories : PHP

IOS http POST requests seem to be empty
Try this function in server side function getRealPOST() { $result = array(); $b = explode("&", urldecode(file_get_contents("php://input"))); foreach($b as $k => $v) { list($ind, $val) = explode("=", $v); $result[$ind] = $val; } return $result; } $post = getRealPOST() echo "<pre>"; print_r($post); hope it will help to get post data in other way not using $_POST

Categories : PHP

How to cache .NET Web API requests (& use w/ AngularJS $http)
Turns out it was a Web API thing. I'd overlooked the fact that the response header clearly stated that caching was disabled. Response as viewed in the Network tab of Google Chrome: Upon further investigation (and as seen in the image above), caching is disabled in Web API controllers. Even the [OutputCache] attribute, which is used in regular MVC controllers, isn't supported. Luckily I found this blog: http://www.strathweb.com/2012/05/output-caching-in-asp-net-web-api/ which lead me to these two solutions: ASP.NET Web API CacheOutput CacheCow I decided to go with CacheOutput as it lets me use attributes like: [CacheOutputUntilToday] which supports server & client side caching. Or if I wanted to just use client-side caching I can use something like: [CacheOutput(ClientTime

Categories : C#

Handling HTTP Requests with C in Nginx
In order to serve compiled binary files with nginx, you need to run another server called FCGI, telling it the path to each binary you wish to serve, then configuring nginx to proxy connections to that server. Example configuration: http { server { listen 80; server_name localhost; location / { fastcgi_pass 127.0.0.1:8000; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcg

Categories : C

Making HTTP requests with Clojure
I cannot make authoritative statements about the reasons why any particular part of old contrib failed to make it into the new contrib, but in general things were moved over when sufficiently many people were interested, including some able and willing to maintain the new libraries. Perhaps in this case there simply wasn't enough interest. Additionally, it is extremely straightforward to build Clojure projects on top of multiple libraries and it is not clear that the presence of an http client library in the core set of libraries or the contrib would make things any simpler and/or easier for developers than they are now, with excellent options available in the wider ecosystem. As for particular examples of such excellent options, I'd point you towards clj-http and http.async.client (in a

Categories : Http

Multiple HTTP requests in one AsyncTask
I suggest using Google Volley. It's a great and simple library for networking and remote image loading. Volley "hides" the whole threading issue in its core, all you have to do is issue a request. No need to manage AsyncTasks. Check it out.

Categories : Android

Reduce HTTP Requests in Grails?
You can use grails static resources to declare images http://www.grails.org/plugin/resources. Because an image is a static resource though, the browser should be caching it and you should only suffer the performance hit the first time. Is that not happening?

Categories : Grails

PHP HTTP 1.1 can not perform partial PUT requests
Well, I finally found an appropriate solution. As Marc B responded, it's impossible to perform partial PUT request (because this type of request must be idempotent by definition). However, if we speak about uploading files to the huge cloud server, it is possible to use appropriate server's API. As far as I can judge, OpenStack (its Swift component to be precise) is popular enough among file storages. So here is brief and clear official documentation. Cloud server, which I use, allows uploading large files only with DLO (Dynamic Large Objects) method, so all you need is: 1) Split your large file into segments (or simply use fseek and fread). 2) Send these segments to one specified directory, which name will further be considered as whole file's name. 3) Send special request (create

Categories : PHP

Responding to HTTP Requests in Eventmachine
If you want something easy then use Thin or Rainbows. It uses Eventmachine inside and provides Rack interface support. # config.ru http_server = proc do |env| response = "Hello World!" [200, {"Connection" => "close", "Content-Length" => response.bytesize.to_s}, [response]] end run http_server And then >> thin start -R config.ru UPD. If you need server to run in parallel you could run it in a Thread require 'thin' class ThreadedServer def initialize(*args) @server = Thin::Server.new(*args) end def start @thread = Thread.start do @server.start end end def stop @server.stop if @thread @thread.join @thread = nil end end end http_server = proc do |env| response = "Hello World!" [200, {"Connection" => "close"

Categories : Ruby

Android http requests and javascript
It's easy to create HTTP(s) request. Take a look at HttpURLConnection class. There is an exemple how to handle cookies. Here you can find a quick introduction to the HttpURLConnection. You won't be able to execute javascript. But if you are creating an app for you webapp you will need to recreate the behaviour. The javascript is useless with a native app.

Categories : Android

wso2 esb catching http requests
For your requirement of posting and getting response form REST backend you can use HTTP end point as shown below <send> <endpoint> <http method="get" uri-template= "http://localhost:8080/rest/api/people/{uri.var.email}"/> </Endpoint> </send> The sample proxt service can be found at [1] For your second requirement you have to write a class mediator and call your API from particular class. Details on class mediator can be found at [2]. Hope this will help you [1]. http://dharshanaw.blogspot.com/2013/09/people-rest-service-sample-proxy.html [2]. http://docs.wso2.org/display/ESB460/Class+Mediator

Categories : Rest

How to set timeout for http.Get() requests in golang?
A quick and dirty way: http.DefaultTransport.(*http.Transport).ResponseHeaderTimeout = time.Second * 45 This is mutating global state w/o any coordination. Yet it might be possibly okay for your url fetcher. Otherwise create a private instance of http.RoundTripper: var myTransport http.RoundTripper = &http.Transport{ Proxy: http.ProxyFromEnvironment, ResponseHeaderTimeout: time.Second * 45, } var myClient = &http.Client{Transport: myTransport} resp, err := myClient.Get(url) ... Nothing above was tested.

Categories : Http

Optimizing HTTP requests in android
Try Volley mate! I changed from AsyncTasks to Volley library and i am pretty pleased from the overall experience! Volley Library

Categories : Java

French Server and HTTP Requests
I just read what "AsynkTasks" is, and I assumed you're working on android, which I know nothing about. I don't know if (or how) this might help you, but if your app can somehow send a request to somewhere that can run this PHP: http://chir.ag/projects/geoiploc/ It returns the geographical location by requester IP. Hope this helps.

Categories : Http

Sending tracking http requests
Can you provide one of the quartile URLs so we can trace it? What happens when you call that quartile directly in the browser, does it work outside of your Ajax call? Are your other events working fine? such as impression, start play, click, etc.. From the HTTP methods you tried GET should work, but POST should not be used with the VAST trackers. Hopefully the server you are hitting is not giving you an incorrect error code, masking an internal error.

Categories : Misc

HTTP requests using the browser console
Depending on browser you have to enable persistent network logging. Its available on both firefox and chrome. Then in the console just execute window.locaiton = 'http://wallbase.cc/wallpaper/3023660'. Check the network log and you'll get your response header, body etc.

Categories : Javascript

Angular not making $http requests immediately
The reason I eventually found the answer in the issues on GitHub (https://github.com/angular/angular.js/issues/2442): v1.1.4... changed the way $http worked so that it was scheduled on nextTick instead of firing immediately. This means that if your $http is scheduled from something that doesn't cause a $digest to fire then your request won't be sent. You can verify that this is the behavior you're seeing by clicking on the page a few times (anywhere) and you should see your request go out. A Solution As the post suggested I triggered a $digest cycle, which caused my $http generated requests to be immediately fired. scope.$apply();

Categories : Angularjs

Best way to send HTTP GET requests ansynchronously in Android?
You could do your own async HTTP GET calls using AsyncTask but I would recommend against it unless you're doing it from a learning point of view. If you want a nice, clean and stable solution I'd suggest that you use the well known Android Asynchronous Http Client 3rd party library. From the site: "An asynchronous callback-based Http client for Android built on top of Apache’s HttpClient libraries. All requests are made outside of your app’s main UI thread, but any callback logic will be executed on the same thread as the callback was created using Android’s Handler message passing." Making a GET is as easy as: AsyncHttpClient client = new AsyncHttpClient(); client.get("http://www.google.com", new AsyncHttpResponseHandler() { @Override public void onSuccess(String response

Categories : Android

How to organize http-requests with responses in javascript?
I believe that what you're looking for is more or less captured within the basics of Object-Oriented Javascript. In it's most basic form you could do: function calleniro(foo,bar) { this.tel = foo+"-"+bar; } contact = new calleniro("555","7777"); if (contact.tel) ... But since you're performing an ajax query, you run into some scoping problems, since this has a different meaning when you're inside GM_xmlhttpRequest. But you can fix this with a closure. The following is a $.ajax example that passes this into the $.ajax function as obj, so instead of using this.tel, we're using obj.tel and avoid the scope problem.. (function(obj) { $.ajax({ async: false, url: url, method: "GET", success: function(data) { obj.tel = data; } });

Categories : Javascript

Store and forward HTTP requests with retries?
There are couple of possibilities. One option is to use Common Address Redundancy Protocol or carp. Brief description from the man page follows. "carp allows multiple hosts on the same local network to share a set of IP addresses. Its primary purpose is to ensure that these addresses are always available, but in some configurations carp can also provide load balancing functionality." It should be possible be configure IP balancing such that when a primary or master http service fails, the secondary or backup http service becomes the master. carp is host oriented as opposed to application service. So when the http service goes down, it should also take down the network interface for carp to do its thing. This means you would need more than one IP address in order to log into the mach

Categories : Http

Handling Airplane Mode with HTTP Requests
Checking for Airplane mode alone is probably not a good idea because you can have wifi on in airplane mode. But there are probably a few possible answers to this but what I do is register a BroadcastReceiver that listens for network state changes with the following permission <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> my receiver looks like this in the manifest <receiver android:name="com.example.NetworkReceiver" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> when that gets fired I check to see if there is network connection or not and keep an app wide boolean in SharedPreferences and I check that boolean every time right be

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.