uri

How to refactor my class so I can unit test it?

I am trying to unit test a class that does SAX parsing and creates an object. This class takes a string as a parameter representing the URL of a document on the internet, parses it and then creates an object based on the contents. I don't want to have the unit tests actually access the network, so I'd like to have a few test xml files t...

Term usage URI or URL or another?

Hi there, as I strive to come up with the best methods name in my designs I struggle on a simple question but still very confusing to me. There are two ways I use for retrieving stylesheets or javascript files: <link href="/myProject/public/styles/master.min.css?v=1274382274" media="screen" rel="stylesheet" type="text/css" /> <link ...

Get individual query parameters from Uri

I have a uri string like: http://example.com/file?a=1&amp;b=2&amp;c=string%20param Is there an existing function that would convert query parameter string into a dictionary same way as ASP.NET Context.Request does it. I'm writing a console app and not a web-service so there is no Context.Request to parse the URL for me. I know that it...

Invalid URI: The format of the URI could not be determined.

I keep getting this error. Invalid URI: The format of the URI could not be determined. the code I have is: Uri uri = new Uri(slct.Text); if (DeleteFileOnServer(uri)) { nn.BalloonTipText = slct.Text + " has been deleted."; nn.ShowBalloonTip(30); } EDIT: the content in slct.Text is ftp.jt-software.net/style.css. What gives?...

How to display data uri scheme into a C# WebBrowser Controler

How can I show an image base64 encoded using WebBrowser control in C#? I used the following code: <img src="data:image/gif;base64,/9j/4AAQSkZJRgABAgAAZABkAA7AAR R894ADkFkb2JlAGTAAAAAAfbAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBw ... uhWkvoJfQO2z/rf4VpL6CX0Dts/63+FaS+gl9A7bP+tthWkvoJfQODCde4qfcg RiNWK3UyUeX9CXpHU43diOK915X5fG/reux5hUAUBftZ" ...

MalformedURLException with file URI

While executing the following code: doc = builder.parse(file); where doc is an instance of org.w3c.dom.Document and builder is an instance of javax.xml.parsers.DocumentBuilder, I'm getting the following exception: Exception in thread "main" java.net.MalformedURLException: unknown protocol: c at java.net.URL.<init>(Unk...

Accessing URL/URI information in Rails in the environments file?

Hi, How would I access the domain name from Rails inside the environments/deveopment.rb? I want to find out whether or not I am on localhost or a real domain. Thank you! ...

Get html that is generated via AJAX in webclient

I often go to a site to look stuff up. I thought to myself: "Hold on. I can program. Why am I going to this site manually when I can write a piece of software that does it for me?". And so I started. I'm using C#, so I found WebClient and Uri. I've managed to get the source code for the site, yet the problem occurred that the specific ...

Optional query string parameters in URITemplate in WCF?

I'm developing some RESTful services in WCF 4.0. I've got a method as below: [OperationContract] [WebGet(UriTemplate = "Test?format=XML&records={records}", ResponseFormat=WebMessageFormat.Xml)] public string TestXml(string records) { return "Hello XML"; } So if i navigate my browser to http://localhost:8000/Ser...

RESTful: Best URI practice in parameterized request of data?

Hi! Trying to get the grips of best URI practice in RESTfulness... Let's say that /service/user.xml returns an xml with all users data /service/user/1.xml returns an xml with data for user id 1 What if I want to get just the email address of the user(s)? /service/user.xml?par=email or /service/user/email.xml for all users? /servic...

Convert file: Uri to File in Android

What's the easiest way to convert from a file: android.net.Uri to a File in Android? Tried the following but it doesn't work: final File file = new File(Environment.getExternalStorageDirectory(), "read.me"); Uri uri = Uri.fromFile(file); File auxFile = new File(uri.toString()); assertEquals(file.getAbsolutePath(), auxFile.getAbsolu...

Javascript src starts with //?

Possible Duplicate: Is it valid to replace with // in a <script src=>? I'm starting to see more and more script references show up like so: <script type="text/javascript" src="//somedomain.com/somescript.js"></script> Note the lack of http: at the beginning of the src attribute. It seems to work fine and avoids the messy ...

Ruby: Can net/http make a GET and POST request simultaneously?

Is it possible to pass both the GET and POST parameters at the same time? uri = URI.parse("http://www.example.com/post.php?a=1&amp;b=2") req = Net::HTTP::Post.new(uri.path, { 'Referer' => "http://www.example.com/referer", 'User-Agent'=> "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)", 'Cookie' => $cookie }) req.set_fo...

pack uri validation

What is the simplest way to verify that a pack uri can be found? For example, given pack://application:,,,Rhino.Mocks;3.5.0.1337;0b3305902db7183f;component/SomeImage.png how would I check whether the image actually exists? Cheers, Berryl ...

Uri for bitmap in subfolder (c# wpf)

I have a wpf app where I'm using an image. To reference the image I use: Uri uri = new Uri("pack://application:,,,/assemblyName;Component/myIcon.png"); BitmapImage(uri) If I add the png directly under the csproj file (with its properties BuildAction=Resource) then it works fine. But I want to move it to a subfolder under the csproj....

Using local files, Android.

Hey Everyone, I am trying to overlay route data in KML files on a MapView. The following code works great: Intent mapIntent = new Intent(Intent.ACTION_VIEW); Uri uri1 = Uri.parse("geo:0,0?q=http://code.google.com/apis/kml/ documentation/KML_Samples.kml"); mapIntent.setData(uri1); startActivity(Intent.createChooser(mapIntent, "Test"));...

How to create a fully qualified hyperlink to a resource dynamically?

In ASP.NET I'd like to create a link which points to a specific Uri and send this link in an email to a user, for instance something like http://www.BlaBla.com/CustomerPortal/Order/9876. I can create the second part of the Uri /CustomerPortal/Order/9876 dynamically in code-behind. My question is: How can I create the base Uri http://www....

Convert URI to GUID

What is a good way to convert a file path (URI) into a System.Guid? I'd like to minimize the possibility of a collision, but I'm happy with a reasonably unique hashing (probably never more than a few dozen/hundred items in the database) ...

Android: getting thumbnails from specific location on sd card

AFAIK accessing thumbnails for images via MediaStore.Images.Thumbnails would generate thumbnails at first attempt, and that's what i need to perform against specific location on sd card. The question is how to make valid URI to content under specific folder? All answers i can find use just MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_...

WPF MediaElement Natural Duration

Hi, I have a MediaElement which I set its Source to a new Uri based on a valid String. For example: MediaElementName.Source = new Uri("string"); The string is a valid path, and after debugging, sometimes it sets the "MediaElementName"'s NaturalDuration, sometimes it does not.. I have been googling for at least 2 hours now with no wo...