-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changing custom script extension links to fwd links (#6500)
* changing custom script extension links to fwd links * moving forward link utility to azure-arm-rest * removing unnecessary new line
- Loading branch information
Showing
7 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Tasks/AzureResourceGroupDeployment/Tests/mock_node_modules/webRequestUtility.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import tl = require("vsts-task-lib/task"); | ||
import webClient = require("./webClient"); | ||
const HttpRedirectCodes: number[] = [301, 302, 307, 308]; | ||
class WebRequestUtility { | ||
public static async getTargetUriFromFwdLink(fwdLink: string) { | ||
tl.debug("Trying to fetch target link from the fwdlink: " + fwdLink); | ||
var httpRequest = new webClient.WebRequest(); | ||
httpRequest.method = 'GET'; | ||
httpRequest.uri = fwdLink; | ||
var httpResponse = await webClient.sendRequest(httpRequest); | ||
if(HttpRedirectCodes.indexOf(httpResponse.statusCode) == -1) { | ||
throw new Error(`HttpResponse statuscode: ${httpResponse.statusCode} is not a valid HTTP redirect code.`); | ||
} | ||
var targetLink: string = httpResponse.headers["location"]; | ||
if(!targetLink) { | ||
throw new Error(`Unable to find location header after HTTP ${httpResponse.statusCode} redirect.`); | ||
} | ||
tl.debug("the target link is : " + targetLink); | ||
return targetLink; | ||
} | ||
} | ||
|
||
export = WebRequestUtility; |