使用Jenkins的http请求插件的v1.8.10(我正在运行1.643),现在支持在请求中POST一个正文 - 所以这个线程不适用.我想知道如何在Pipeline(v2.1)Groovy脚本中使用此功能?片段生成器不包括这个新字段,所以我没有建立的例子.
我已经尝试了各种方法将JSON数据放入请求体,但我的Tomcat服务器始终返回http 400状态代码: The request sent by the client was syntactically incorrect.
我尝试过的事情:
def toJson = {
input ->
groovy.json.JsonOutput.toJson(input)
}
def body = [
displayName: [
text: "smoke test"],
description: [
text: "for smoke testing"],
genusTypeId: "type"
]
response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: toJson(body), url: "https://${host}", validResponseCodes: '200'
Run Code Online (Sandbox Code Playgroud)
def body = [
displayName: [
text: "smoke test"],
description: [
text: "for smoke testing"],
genusTypeId: "type"
]
response = httpRequest consoleLogResponseBody: …Run Code Online (Sandbox Code Playgroud) groovy http-request jenkins jenkins-plugins jenkins-pipeline
是否有任何工具可以跟踪程序发送的确切HTTP请求?
我有一个应用程序作为网站的客户端,并促进某些任务(特别是它是一个机器人,根据一些预定义的标准,在社交借贷网站上自动提供),我有兴趣监控实际的HTTP请求,它使.
有关该主题的任何教程?
我正在尝试在请求过滤器中获取请求的表单参数:
@Override
public ContainerRequest filter(final ContainerRequest request) {
final Form formParameters = request.getFormParameters();
//logic
return request;
}
Run Code Online (Sandbox Code Playgroud)
但是,表格似乎总是空的.该HttpRequestContext.getFormParameters()文件说:
获取请求实体的表单参数.
此方法将确保缓冲请求实体,以便应用程序可以使用它.
返回: 表单参数,如果有请求实体且内容类型为"application/x-www-form-urlencoded",否则将返回不包含参数的实例.
我的资源是注释的@Consumes("application/x-www-form-urlencoded"),虽然它在请求过滤器之后才会匹配 - 这就是为什么这不起作用?
我尝试做一些研究,但未能找到任何确凿的证据证明这是否可行.有这个为期4年的讨论,Paul Sandoz说:
如果您正在使用泽西过滤器或使用,
HttpRequestContext您可以获得如下表单参数:[到Jersey 1.1.1的断开链接HttpRequestContext.getFormParameters]
我还发现了这个有关如何在请求过滤器中获取multipart/form-data表单字段的3年讨论.在其中,Paul Sandoz使用以下代码:
// Buffer
InputStream in = request.getEntityInputStream();
if (in.getClass() != ByteArrayInputStream.class) {
// Buffer input
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ReaderWriter.writeTo(in, baos);
} catch (IOException ex) {
throw new ContainerException(ex);
}
in = new …Run Code Online (Sandbox Code Playgroud) 我有一个简单的角度应用程序,有两个使用ngRoute加载的视图.当用户在视图之间导航以及用户离开页面时(刷新窗口,关闭选项卡或关闭浏览器),我需要在服务器上进行一些清理.
我的第一站就在这里:当用户离开页面时在angularjs中显示警报.它解决了用户在视图之间导航的第一种情况.我已经像这样处理了清理工作:
$scope.$on('$locationChangeStart', function (event) {
var answer = confirm("Are you sure you want to leave this page?")
if (answer) {
api.unlock($scope.id); //api is a service that I wrote. It uses angular $http service to handle communications and works in all other cases.
} else {
event.preventDefault();
}
});
Run Code Online (Sandbox Code Playgroud)
但是,我无法处理用户离开页面的情况.按照上述答案和此Google网上论坛帖子:https://groups.google.com/forum/#!topic / angular/-PfujIEdeCY我试过这个:
window.onbeforeunload = function (event) {
api.unlock($scope.id); //I don't necessarily need a confirmation dialogue, although that would be helpful.
};
Run Code Online (Sandbox Code Playgroud)
但它没有用.然后我在这里读到: 如何在onbeforeunload上执行ajax函数? …
我需要发送一个HTTP请求,我可以这样做,但我在Backendless中的API需要HTTP请求标头中的application-id和secret-key.你能帮忙把它添加到我的代码中吗?谢谢
let urlString = "https://api.backendless.com/v1/data/Pub"
let session = NSURLSession.sharedSession()
let url = NSURL(string: urlString)!
session.dataTaskWithURL(url){(data: NSData?,response: NSURLResponse?, error: NSError?) -> Void in
if let responseData = data
{
do{
let json = try NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.AllowFragments)
print(json)
}catch{
print("Could not serialize")
}
}
}.resume()
Run Code Online (Sandbox Code Playgroud) http http-headers http-request http-request-parameters swift
所以我刚刚为firebug下载了yslow,并查看了我正在构建的网站的结果.
我看到建议,例如,使用ETags,我的静态组件的无cookie域,并添加过期标头.
我在想,好吧我可以去解决这些问题但是我可以先做一些其他的优化,例如缓存数据库调用的结果或类似的东西.
我不认为这个网站会得到"那么多"的使用来保证YSlow的建议.
我知道你应该在你知道自己需要之前不进行优化,但我认为像ETags和expires标题这样的东西肯定只会在流量非常大的网站上发挥作用.
例如,我写了一个糟糕的实现,每次请求对数据库进行5次(相对较小的)调用,而YSlow告诉我我的14个图像不在无cookie域中,那么这两个优化中的哪一个应该先解决?
是否有任何直接的方法来发出HTTP请求并获得原始的,未解析的响应(特别是标题)?
所以我的时间表总是这样
http://see.kirkstrobeck.com/TjQU/Screen%20Shot%202014-02-04%20at%206.40.14%20PM.png
该index.html负载,然后询问其他文件.我想有没有办法让响应请求的标题说明应该删除哪些文件?所以它看起来像这样..
http://see.kirkstrobeck.com/TjKl/Screen%20Shot%202014-02-04%20at%206.40.14%20PM.png
也许像..
<?
header('fileGetRequest: /js/common.js');
header('fileGetRequest: /css/common.css');
?>
Run Code Online (Sandbox Code Playgroud) 我刚刚将一个PageKit(mod_perl)应用程序转换为Plack.这意味着我现在需要一些方法来强制执行Apache2 :: Reques 先前已经处理过的POST_MAX/MAX_BODY .最简单的方法可能只是将nginx放在应用程序前面,但是应用程序已经位于HAProxy后面,我不知道如何使用HAProxy执行此操作.
那么,我的问题是我如何在不首先阅读整个请求的情况下在Plack :: Middleware中强制执行最大体型?
具体来说,我关注文件上传.通过检查大小普拉克::支持::上传是为时已晚,因为整个身体会一直在这一点上阅读.该应用程序将通过Starman部署,所以psgix.streaming应该是true.
我正在努力使用Postman Chrome扩展程序创建POST多部分/混合请求.我一直在获得HTTP 500.
已经经历过这个问题,但遗憾的是解决方案对我不起作用.
这是我的卷曲请求,对我有用.
curl -H"Content-Type:multipart/form-data"-F"merchantLogo =@offerlogo-320-320.png; type = image/png"-F"merchantDetails =@merchant.json; type = application/json" -X PATCH localhost:5000/api/merchants/57035bda0c74362faf5937f2/details -i -v
我得到了这样的回应
{"code": 500,
"message": "There was an error processing your request. It has been logged (ID 034bec7815baca2e)."}
Run Code Online (Sandbox Code Playgroud)
不知何故,当从POSTMAN调用时,merchantDetails总是被传递为null,并且在从curl进行调用时正确传递.
任何帮助将非常感激.
编辑1:
我将POSTMAN的请求复制为curl,
卷曲' 的http://本地主机:5000/API /商家/ 5714d8e060b2a79e62227d1a /详细信息 ' -X PATCH -H '杂注:无缓存' -H '来源:铬扩展:// fdmmgilgnpjigdojojpjoooidkmcomcm' -H"的Accept-Encoding: gzip,deflate,sdch'-H'Accept-Language:en-GB,en-US; q = 0.8,en; q = 0.6'-H'User-Agent:Mozilla/5.0(X11; Linux x86_64)AppleWebKit/537.36 (KHTML,与Gecko一样)Chrome/49.0.2623.87 Safari/537.36'-H'内容类型:multipart/form-data; boundary = ---- WebKitFormBoundaryxRZ6VKzFV40ZFIsd'-H'接受:/ ' - H'缓存控制:无缓存'-H'Cookie:JSESSIONID …
http-request ×10
http-headers ×4
http ×3
angularjs ×1
curl ×1
groovy ×1
http-post ×1
java ×1
javascript ×1
jenkins ×1
jersey ×1
jersey-1.0 ×1
monitoring ×1
optimization ×1
perl ×1
plack ×1
postman ×1
psgi ×1
python ×1
swift ×1
trace ×1
yslow ×1