@@ -229,6 +229,9 @@ def external_url_handler(error, endpoint, **values):
229229 that this is for building URLs outside the current application, and not for
230230 handling 404 NotFound errors.
231231
232+ .. versionadded:: 0.10
233+ The `_scheme` parameter was added.
234+
232235 .. versionadded:: 0.9
233236 The `_anchor` and `_method` parameters were added.
234237
@@ -241,6 +244,8 @@ def external_url_handler(error, endpoint, **values):
241244 :param _external: if set to `True`, an absolute URL is generated. Server
242245 address can be changed via `SERVER_NAME` configuration variable which
243246 defaults to `localhost`.
247+ :param _scheme: a string specifying the desired URL scheme. The `_external`
248+ parameter must be set to `True` or a `ValueError` is raised.
244249 :param _anchor: if provided this is added as anchor to the URL.
245250 :param _method: if provided this explicitly specifies an HTTP method.
246251 """
@@ -283,7 +288,14 @@ def external_url_handler(error, endpoint, **values):
283288
284289 anchor = values .pop ('_anchor' , None )
285290 method = values .pop ('_method' , None )
291+ scheme = values .pop ('_scheme' , None )
286292 appctx .app .inject_url_defaults (endpoint , values )
293+
294+ if scheme is not None :
295+ if not external :
296+ raise ValueError ('When specifying _scheme, _external must be True' )
297+ url_adapter .url_scheme = scheme
298+
287299 try :
288300 rv = url_adapter .build (endpoint , values , method = method ,
289301 force_external = external )
0 commit comments