Questions tagged [uri]

A Uniform Resource Identifier (or URI) is a string of characters used to identify a name or resource. URI is legacy terminology. In most cases, the term URL should be used instead.

A Uniform Resource Identifier (or URI) is a string of characters used to identify a name or resource.

Note: The current URL Standard at https://url.spec.whatwg.org/#url-representation supersedes RFC 3986 and dispenses with the use of the term URI, as documented in its Goals section:

Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone. URL also easily wins the search result popularity contest.

But the information below documents URI in terms of the legacy RFC 3986 spec.


Structure

A URI can be a Uniform Resource Locator , a Uniform Resource Name , or both.

RFC 3986 defines a URI as composed of the following parts:

    foo://example.com:8042/over/there?name=ferret#nose
    \_/   \______________/\_________/ \_________/ \__/
     |           |            |            |        |
  scheme     authority       path        query   fragment

Then defining relative URIs (Section 5.2), you can omit any of those sections, always starting from the left. In pseudo-code, it looks like this:

 result = ""

  if defined(scheme) then
     append scheme to result;
     append ":" to result;
  endif;

  if defined(authority) then
     append "//" to result;
     append authority to result;
  endif;

  append path to result;

  if defined(query) then
     append "?" to result;
     append query to result;
  endif;

  if defined(fragment) then
     append "#" to result;
     append fragment to result;
  endif;

  return result;

The URI you are describing is a scheme-less relative URI.

Examples

For example, in the following URI:

https://stackoverflow.com/questions/tagged/uri?sort=newest&pagesize=50#questions

... the components are:

  • scheme: https

  • hierarchical part: //stackoverflow.com/questions/tagged/uri

  • query: sort=newest&pagesize=50

  • fragment: questions

The precise syntax of the individual components varies depending on the scheme. Here are some examples:

  • mailto:nobody@example.com?subject=Hello&body=Is%20anybody%20home%3F

  • data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=

  • urn:ietf:rfc:3986

URL

A URL is a URI but is more specific. In addition to identifying a web resource, a URL specifies the means of acting upon or obtaining the representation, specifying both its primary access mechanism and network location.

For example, the URL http://example.org/wiki/Main_Page refers to a resource identified as /wiki/Main_Page whose representation, in the form of HTML and related code, obtainable via HyperText Transfer Protocol (http) from a network host whose domain name is example.org.

URI Reference

A URI reference may take the form of a full URI, or just the scheme-specific portion of one, or even some trailing component thereof – even the empty string. An optional fragment identifier, preceded by #, may be present at the end of a URI reference. The part of the reference before the # indirectly identifies a resource, and the fragment identifier identifies some portion of that resource.

To derive a URI from a URI reference, software converts the URI reference to 'absolute' form by merging it with an absolute 'base' URI according to a fixed algorithm. The system treats the URI reference as relative to the base URI, although in the case of an absolute reference, the base has no relevance. The base URI typically identifies the document containing the URI reference, although this can be overridden by declarations made within the document or as part of an external data transmission protocol. If the base URI includes a fragment identifier, it is ignored during the merging process. If a fragment identifier is present in the URI reference, it is preserved during the merging process.

Web document markup languages frequently use URI references to point to other resources, such as external documents or specific portions of the same logical document.

Uses of URI references in markup languages

  • In HTML, the value of the src attribute of the img element provides a URI reference, as does the value of the href attribute of the a or link element.
  • In XML, the system identifier appearing after the SYSTEM keyword in a DTD is a fragmentless URI reference.
  • In XSLT, the value of the href attribute of the xsl:import element/instruction is a URI reference; likewise the first argument to the document() function.

Examples of absolute URIs

Examples of URI references

6139 questions
2
votes
1 answer

Blank - Black Image control in WPF if image source is absolute Uri

I use on listbox control own datatemplate. Listbox item consist one image control and some textblock. On image source I bind property type of Uri (absolute url - for example: http://u.aimg.sk/fotky/1730/71/17307141.jpg?v=2) Listbox have about 50 -…
user572844
2
votes
1 answer

Gmail puts shared Uri as a "to" receiver field

I was trying to use following piece of code from this tutorial to share files from my own app to other application like Gmail. File imageFile = ...; Uri uriToImage = FileProvider.getUriForFile( context, FILES_AUTHORITY, imageFile); Intent…
Nava
  • 368
  • 2
  • 11
2
votes
0 answers

Use Selection and Selection Args instead of URI matcher

I am confused the whole point of using URI matcher is to identify whether we want to work on particular row or the whole table. so in case we want to work on particular row with id "ID" we attach id to the path of URI and then URI matcher will…
2
votes
0 answers

ImageViewer intent shows blank image

I save an image under cache at runtime. Then I want to read and show it with system image viewer. I use below code for under api level 24: File f = new File(getApplicationContext().getCacheDir(), "sample.png"); Intent intent = new…
zakjma
  • 2,030
  • 12
  • 40
  • 81
2
votes
1 answer

DIfference between Uri.fromParts and Uri.parse?

I'm creating an Intent for Android, to send e-mails. And I'm getting confused about the behavior of Uri.fromParts. Mi code: This works fine! uri=Uri.parse( "mailto:" + toAddress + (subject != null ? ("?" + "subject=" +…
Sourcerer
  • 1,891
  • 1
  • 19
  • 32
2
votes
1 answer

onRequestPermissionsResult calling automatically with not Gratned results

My problem is that @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { calling immediatelly after ActivityCompat.requestPermissions(this, new…
Eugene Voronoy
  • 1,384
  • 1
  • 14
  • 18
2
votes
1 answer

Net::HTTP send request xml

I need to send the request in the form of xml. uri =URI('https://fs.example.com:8443/services/trust/13/usermixed') http = Net::HTTP.new(uri) request = Net::HTTP::Post.new(uri) request['Content-Type'] = 'application/soap+xml;…
rostov-7
  • 25
  • 1
  • 4
2
votes
1 answer

Save and retrieve Intent from SharedPreferences

In my app I need to save Intend data for later use (on app relaunch). What I've tried is: To save: Parse Intent into Uri to get String >> Put String in SharedPreferences To Retrieve: Get String from SharedPreferences >> Use obtained String to parse…
Muhammad Shuja
  • 642
  • 5
  • 18
2
votes
1 answer

Resource registered by this uri is not recognized

I have a problem with my android studio. I have android studio 3.0.1 on mac and I'm having a problem with the URI
XSplit
  • 21
  • 4
2
votes
1 answer

NGINX + Docker Compose Routing Issues

I have a docker compose file comprising of two microservices that I want to leverage URI routing for in order to handle CORS. Here is my compose file: version: "3.1" services: auth-api: image: xxxx/auth-api:latest restart: always …
Joel Holmes
  • 943
  • 2
  • 12
  • 23
2
votes
1 answer

content-security-policy-report-only report-uri with fully qualified absolute URL

when using content-security-policy-report-only report-uri, is it possible to have a fully-qualified absolute URL for the 'report-uri' value? All examples I see are relative values that go back to the application itself.
Michael Remijan
  • 687
  • 7
  • 22
2
votes
1 answer

Android how to install apk stored in internal storage

I've successfully downloaded my apk file to internal storage. However when running it I get an "No activity found to handle intent" error. Here is my code to run the apk file. // Old version if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) { File…
mocode10
  • 589
  • 1
  • 6
  • 23
2
votes
2 answers

ContactsContract lookup Phone Number by Contact Id

I am attempting to lookup the phone number for contacts by their contactId, bll results are returning - Phone Number: 1 I've tried using other examples around SO but I keep getting a 0 count on the cursor Uri uri =…
cynicaljoy
  • 2,047
  • 1
  • 18
  • 25
2
votes
2 answers

Issue converting Image Uri from gallery to bitmap Android

I am having trouble converting from an image uri to a bitmap to then show it in an image view, yet I am getting an unhandled exception when converting into a bitmap. Here is the code: public class MainActivity extends AppCompatActivity { public…
2
votes
2 answers

Azure Rate Card api query using URIBuilder

I am having difficulty building the URL correctly using URIBuilder in a grrovy script. This is what it the documentation says it should look like -…
Mondo
  • 163
  • 13