newLISP HTTP Basic Authentication

Source: Internet
Author: User
Tags base64 sha1

HTTP Basic Authentication original easy, reference document: http://zh.wikipedia.org/wiki/HTTP%E5%9F%BA%E6%9C%AC%E8%AE%A4%E8%AF%81

Use username and password: Separate, then encode with base64. Finally, the page is requested using the HTTP GET method

The following small piece of code calls Jenkins's remote API with newLISP:

[email protected]:~$./HTTP.LSP hello<freestylebuild><action><cause><shortdescription >started by upstream project "Detail_summary_pipeline" build number 3</shortdescription><upstreambuild >3</upstreamBuild><upstreamProject>detail_summary_pipeline</upstreamProject>< upstreamurl>job/detail_summary_pipeline/</upstreamurl></cause></action><action>< /action><action><buildsbybranchname><refsremotesorigindevelop><buildnumber>8</ Buildnumber><marked><sha1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</sha1><branch> <sha1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</sha1><name>refs/remotes/origin/develop</ name></branch></marked><revision><sha1>8fe197b461d99b198551d9f50f3dc73cd5424c0b< /sha1><branch><sha1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</sha1><name>refs/ Remotes/origin/develop</name></branch></revision></refsremotesorigindevelop></buildsbybranchname>< Lastbuiltrevision><sha1>8fe197b461d99b198551d9f50f3dc73cd5424c0b</sha1><branch><sha1 >8fe197b461d99b198551d9f50f3dc73cd5424c0b</SHA1><name>refs/remotes/origin/develop</name> </branch></lastbuiltrevision><remoteurl>[email protected]:d Atawarehouse/log_ Aggregation.git</remoteurl><scmname></scmname></action><action></action> <action></action><action></action><building>false</building><duration >105297</duration><estimatedduration>95546</estimatedduration><fulldisplayname>sum_ User_query_day_cloud #8 </fullDisplayName><id>2014-10-02_11-01-53</id><keepLog>false< /keeplog><number>8</number><result>success</result><timestamp>1412218913296 </timestamp><url>http://10.100.86.22:8080/job/sum_user_query_day_cloud/8/</url><builton>slave25</builton>< Changeset><kind>git</kind></changeset></freestylebuild>

HTTP.LSP source code such as the following:

#!/usr/bin/newlisp (println "Hello") (set ' User-pass "User:pwd") (Set ' Auth (append "Authorization:basic" (Base64-enc User-pass) ("\ r \ n")) (set ' XML (Get-url "Http://your_jenkins/job/your_job/lastBuild/api/xml" auth) "(println XML) ( Exit

Note that the Get-url function is powerful, here the 5000 refers to the time-out, Auth is to put the encoded username and password in the header to send out.


newLISP HTTP Basic Authentication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.