on master help sign in
Misc documentation corrections and minor tweaks
commitae160e623fb8c76039142d93a992d21e3485dbab authormrkkrp <markkarpov92@gmail.com> dateTue 28 Nov 2017, 15:36 (9 years ago) parent284273c
2 files changed+32−31
CHANGELOG.md+6−6 Network/HTTP/Req.hs+26−25
CHANGELOG.md+6−6
@@ -41,12 +41,12 @@
4141
4242## Req 0.2.0
4343
44−* Added support for multipart form data in form of `ReqBodyMultipart` body
45− option and `reqBodyMultipart` helper function. This also required a change
46− in type signature of `getRequestContentType`, which now takes `body`, not
47− `Proxy body` because we need to extract boundary from `body` and put it
48− into `Content-Type` header. This change, however, shouldn't be too
49− dangerous for end-users.
44+* Added support for multipart form data in the form of `ReqBodyMultipart`
45+ body option and `reqBodyMultipart` helper function. This also required a
46+ change in the type signature of `getRequestContentType`, which now takes
47+ `body`, not `Proxy body` because we need to extract boundary from `body`
48+ and put it into `Content-Type` header. This change, however, shouldn't be
49+ too dangerous for end-users.
5050
5151* Added support for OAuth 1.0 authentication via `oAuth1` option.
5252
Network/HTTP/Req.hs+26−25
@@ -419,8 +419,8 @@ req method url body Proxy options = req' method url body options $ \request mana
419419-- that allows to perform a request in arbitrary fashion.
420420--
421421-- This function /does not/ perform handling\/wrapping exceptions, checking
422−-- response, and retrying. It only prepares 'L.Request' and allows you to
423−-- use it.
422+-- response (with 'httpConfigCheckResponse'), and retrying. It only prepares
423+-- 'L.Request' and allows you to use it.
424424--
425425-- @since 0.3.0
426426
@@ -438,7 +438,6 @@ req'
438438 -> m a
439439req' method url body options m = do
440440 config@HttpConfig {..} <- getHttpConfig
441− manager <- liftIO (readIORef globalManager)
442441 let -- NOTE First appearance of any given header wins. This allows to
443442 -- “overwrite” headers when we construct a request by cons-ing.
444443 nubHeaders = Endo $ \x ->
@@ -456,7 +455,7 @@ req' method url body options m = do
456455 getRequestMod url <>
457456 getRequestMod (Womb method :: Womb "method" method)
458457 request <- finalizeRequest options request'
459− m request manager
458+ withReqManager (m request)
460459
461460-- | Global 'L.Manager' that 'req' uses. Here we just go with the default
462461-- settings, so users don't need to deal with this manager stuff at all, but
@@ -496,8 +495,8 @@ withReqManager m = liftIO (readIORef globalManager) >>= m
496495-- When writing a library, keep your API polymorphic in terms of
497496-- 'MonadHttp', only define instance of 'MonadHttp' in final application.
498497-- Another option is to use @newtype@ wrapped monad stack and define
499−-- 'MonadHttp' for it. As of version /0.4.0/, the 'Req' monad is provided
500−-- for this out-of-the-box.
498+-- 'MonadHttp' for it. As of version /0.4.0/, the 'Req' monad that follows
499+-- this strategy is provided out-of-the-box.
501500
502501-- | A type class for monads that support performing HTTP requests.
503502-- Typically, you only need to define the 'handleHttpException' method
@@ -516,9 +515,9 @@ class MonadIO m => MonadHttp m where
516515 -- | Return 'HttpConfig' to be used when performing HTTP requests. Default
517516 -- implementation returns its 'def' value, which is described in the
518517 -- documentation for the type. Common usage pattern with manually defined
519− -- 'getHttpConfig' is to return some hard-coded value, or value extracted
520− -- from 'Control.Monad.Reader.MonadReader' if a more flexible approach to
521− -- configuration is desirable.
518+ -- 'getHttpConfig' is to return some hard-coded value, or a value
519+ -- extracted from 'Control.Monad.Reader.MonadReader' if a more flexible
520+ -- approach to configuration is desirable.
522521
523522 getHttpConfig :: m HttpConfig
524523 getHttpConfig = return def
@@ -536,8 +535,8 @@ data HttpConfig = HttpConfig
536535 -- value: 10.
537536 , httpConfigAltManager :: Maybe L.Manager
538537 -- ^ Alternative 'L.Manager' to use. 'Nothing' (default value) means
539− -- that default implicit manager will be used (that's what you want in
540− -- 99% of cases).
538+ -- that the default implicit manager will be used (that's what you want
539+ -- in 99% of cases).
541540 , httpConfigCheckResponse :: forall r. HttpResponse r => L.Request -> r -> IO ()
542541 -- ^ Function to check the response immediately after receiving the
543542 -- status and headers. This is used for throwing exceptions on
@@ -713,7 +712,7 @@ instance HttpMethod PATCH where
713712 httpMethodName Proxy = Y.methodPatch
714713
715714-- | A type class for types that can be used as an HTTP method. To define a
716−-- non-standard method, follow this example that defines COPY:
715+-- non-standard method, follow this example that defines @COPY@:
717716--
718717-- > data COPY = COPY
719718-- >
@@ -954,7 +953,7 @@ instance QueryParam FormUrlEncodedParam where
954953-- | Multipart form data. Please consult the
955954-- "Network.HTTP.Client.MultipartFormData" module for how to construct
956955-- parts, then use 'reqBodyMultipart' to create actual request body from the
957−-- parts. 'reqBodyMultipart' is the only way to get a value of type
956+-- parts. 'reqBodyMultipart' is the only way to get a value of the type
958957-- 'ReqBodyMultipart', as its constructor is not exported on purpose.
959958--
960959-- @since 0.2.0
@@ -1063,9 +1062,9 @@ instance HttpBody body => RequestComponent (Womb "body" body) where
10631062-- the last argument of 'req' to specify no optional parameters, or combine
10641063-- 'Option's using 'mappend' (or @('<>')@) to have several of them at once.
10651064
1066−-- | Opaque 'Option' type is a 'Monoid' you can use to pack collection of
1067−-- optional parameters like query parameters and headers. See sections below
1068−-- to learn which 'Option' primitives are available.
1065+-- | The opaque 'Option' type is a 'Monoid' you can use to pack collection
1066+-- of optional parameters like query parameters and headers. See sections
1067+-- below to learn which 'Option' primitives are available.
10691068
10701069data Option (scheme :: Scheme) =
10711070 Option (Endo (Y.QueryText, L.Request)) (Maybe (L.Request -> IO L.Request))
@@ -1096,8 +1095,8 @@ withQueryParams f = Option (Endo (first f)) Nothing
10961095withRequest :: (L.Request -> L.Request) -> Option scheme
10971096withRequest f = Option (Endo (second f)) Nothing
10981097
1099−-- | A helper to create an 'Option' that adds a finalizer (request
1100−-- transformation that is applied after all other modifications).
1098+-- | A helper to create an 'Option' that adds a finalizer (an IO-enabled
1099+-- request transformation that is applied after all other modifications).
11011100
11021101asFinalizer :: (L.Request -> IO L.Request) -> Option scheme
11031102asFinalizer = Option mempty . pure
@@ -1293,7 +1292,7 @@ oAuth2Token token = asFinalizer
12931292
12941293-- | Specify the port to connect to explicitly. Normally, 'Url' you use
12951294-- determines the default port: @80@ for HTTP and @443@ for HTTPS. This
1296−-- 'Option' allows to choose arbitrary port overwriting the defaults.
1295+-- 'Option' allows to choose an arbitrary port overwriting the defaults.
12971296
12981297port :: Int -> Option scheme
12991298port n = withRequest $ \x ->
@@ -1482,7 +1481,7 @@ responseCookieJar = L.responseCookieJar . toVanillaResponse
14821481-- $new-response-interpretation
14831482--
14841483-- To create a new response interpretation you just need to make your data
1485−-- type an instance of 'HttpResponse' type class.
1484+-- type an instance of the 'HttpResponse' type class.
14861485
14871486-- | A type class for response interpretations. It allows to fully control
14881487-- how request is made and how its body is parsed.
@@ -1504,7 +1503,7 @@ class HttpResponse response where
15041503 getHttpResponse :: L.Request -> L.Manager -> IO response
15051504
15061505 -- | Construct a “preview” of response body. It is recommend to limit the
1507− -- length to 1024 bytes. This is mainly useful for inclusion of response
1506+ -- length to 1024 bytes. This is mainly used for inclusion of response
15081507 -- body fragments in exceptions.
15091508 --
15101509 -- __Note__: in versions 0.3.0–0.4.0 this function returned @'IO'
@@ -1522,14 +1521,16 @@ class HttpResponse response where
15221521-- 'RequestComponent' changing\/overwriting something in it. 'Endo' is a
15231522-- monoid of endomorphisms under composition, it's used to chain different
15241523-- request components easier using @('<>')@.
1524+--
1525+-- __Note__: this type class is not a part of the public API.
15251526
15261527class RequestComponent a where
15271528
15281529 -- | Get a function that takes a 'L.Request' and changes it somehow
1529− -- returning another 'L.Request'. For example HTTP method instance of
1530− -- 'RequestComponent' just overwrites method. The function is wrapped in
1531− -- 'Endo' so it's easier to chain such “modifying applications” together
1532− -- building bigger and bigger 'RequestComponent's.
1530+ -- returning another 'L.Request'. For example, the 'HttpMethod' instance
1531+ -- of 'RequestComponent' just overwrites method. The function is wrapped
1532+ -- in 'Endo' so it's easier to chain such “modifying applications”
1533+ -- together building bigger and bigger 'RequestComponent's.
15331534
15341535 getRequestMod :: a -> Endo L.Request
15351536