Explain http keep-alive mechanism

There is overhead in establishing a new TCP connection (DNS lookups, TCP handshake, SSL/TLS handshake, etc). Without a keep-alive, every HTTP request has to establish a new TCP connection, and then close the connection once the response has been sent/received. A keep-alive allows an existing TCP connection to be re-used for multiple requests/responses, thus avoiding …

Read more

Loading a webpage through UIWebView with POST parameters

Create POST URLRequest and use it to fill webView NSURL *url = [NSURL URLWithString: @”http://your_url.com”]; NSString *body = [NSString stringWithFormat: @”arg1=%@&arg2=%@”, @”val1″,@”val2″]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url]; [request setHTTPMethod: @”POST”]; [request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]]; [webView loadRequest: request];

Python’s `urllib2`: Why do I get error 403 when I `urlopen` a Wikipedia page?

Wikipedias stance is: Data retrieval: Bots may not be used to retrieve bulk content for any use not directly related to an approved bot task. This includes dynamically loading pages from another website, which may result in the website being blacklisted and permanently denied access. If you would like to download bulk content or mirror …

Read more

Download text/csv content as files from server in Angular

$http service returns a promise which has two callback methods as shown below. $http({method: ‘GET’, url: ‘/someUrl’}). success(function(data, status, headers, config) { var anchor = angular.element(‘<a/>’); anchor.attr({ href: ‘data:attachment/csv;charset=utf-8,’ + encodeURI(data), target: ‘_blank’, download: ‘filename.csv’ })[0].click(); }). error(function(data, status, headers, config) { // handle error });

How to write a download progress indicator in Python?

There’s a text progress bar library for python at http://pypi.python.org/pypi/progressbar/2.2 that you might find useful: This library provides a text mode progressbar. This is tipically used to display the progress of a long running operation, providing a visual clue that processing is underway. The ProgressBar class manages the progress, and the format of the line …

Read more

How to intercept all http requests including form submits

https://developer.mozilla.org/en/docs/Web/API/Service_Worker_API Service workers essentially act as proxy servers that sit between web applications, and the browser and network (when available). It takes the form of a JavaScript file that can control the web page/site it is associated with, intercepting and modifying navigation and resource requests You register a service worker in your application code from …

Read more