Setting a custom userAgent in HTML or JavaScript

This is working for me. Object.defineProperty(navigator, ‘userAgent’, { get: function () { return ‘Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0)’; } }); It is an updated version of code4coffee’s answer as Object.prototype.__defineGetter__() is deprecated: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__

Parametrized get request in Ruby?

Since version 1.9.2 (I think) you can actually pass the parameters as a hash to the URI::encode_www_form method like this: require ‘uri’ uri = URI.parse(‘http://www.example.com/search.cgi’) params = { :q => “ruby”, :max => “50” } # Add params to URI uri.query = URI.encode_www_form( params ) and then fetch the result, depending on your preference require … Read more

post and get with same method signature

Rename the second method to something else like “Friends_Post” and then you can add [ActionName(“Friends”)] attribute to the second one. So the requests to the Friend action with POST as request type, will be handled by that action. // Get: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Friends() { // do some stuff return View(); } // Post: [ActionName(“Friends”)] … Read more

WWW/UnityWebRequest POST/GET request won’t return the latest data from server/url

This is happening because resources caching is enabled on the Server. Three possible solutions I know about: 1.Disable resources caching on the server. Instructions are different for every web server. Usually done in .htaccess. 2.Make each request with unique timestamp. The time should in Unix format. This method will not work on iOS. You are … Read more

HTTP GET Request, ASP – I’m lost!

Your code should look like this:- Function GetTextFromUrl(url) Dim oXMLHTTP Dim strStatusTest Set oXMLHTTP = CreateObject(“MSXML2.ServerXMLHTTP.3.0”) oXMLHTTP.Open “GET”, url, False oXMLHTTP.Send If oXMLHTTP.Status = 200 Then GetTextFromUrl = oXMLHTTP.responseText End If End Function Dim sResult : sResult = GetTextFromUrl(“http://www.certigo.com/demo/request.asp”) Note use ServerXMLHTTP from within ASP, the XMLHTTP component is designed for client side usage and … Read more

How to set Cookies at Http Get method using Java

To be sure, you should be gathering the cookies from the response’s Set-Cookie headers. To send them back in the subsequent requests, you should set them one by one using URLConnection#addRequestProperty(). Basically: // … // Grab Set-Cookie headers: List<String> cookies = connection.getHeaderFields().get(“Set-Cookie”); // … // Send them back in subsequent requests: for (String cookie : … Read more

Maven: downloading files from url

If the file is a Maven dependency, you could use the Maven Dependency Plugin which has a get goal. For any file, you could use the Antrun plugin to call Ant’s Get task. Another option would be the maven-download-plugin, it has been precisely created to facilitate this kind of things. It’s not very actively developed … Read more