Difference between revisions of "Url"

From HaskellWiki
Jump to navigation Jump to search
(Deleting page that hasn't been edited for over 10 years)
m (Reverted edits by Tomjaguarpaw (talk) to last revision by Henk-Jan van Tuyl)
 
Line 1: Line 1:
  +
The URL library provides a module Network.URL that makes it easy to work with HTTP URLs.
  +
  +
Links:
  +
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/url Download package]
  +
* [http://github.com/yav/url/tree/master Repository on GitHub]
  +
  +
Please feel free to update this page with extra documentation and examples of how to use the package.
  +
  +
The following example shows how to parse a URL and then add some parameters to it:
  +
import Network.URL
  +
  +
test x = case importURL x of
  +
Just u -> print $ exportURL $ add_param u ("Hello","World?")
  +
Nothing -> print "invalid URL"
  +
  +
Here is some sample output:
  +
*Main> test "http://www.haskell.org"
  +
"http://www.haskell.org/?Hello=World%3f"
  +
  +
Note that the question mark in the parameters was escaped automatically.
  +
  +
[[Category:Packages]]
  +
[[Category:Libraries]]

Latest revision as of 15:18, 6 February 2021

The URL library provides a module Network.URL that makes it easy to work with HTTP URLs.

Links:

Please feel free to update this page with extra documentation and examples of how to use the package.

The following example shows how to parse a URL and then add some parameters to it:

import Network.URL

test x = case importURL x of
           Just u  -> print $ exportURL $ add_param u ("Hello","World?")
           Nothing -> print "invalid URL"

Here is some sample output:

*Main> test "http://www.haskell.org"
"http://www.haskell.org/?Hello=World%3f"

Note that the question mark in the parameters was escaped automatically.