我正在使用http://dingyonglaw.github.com/bootstrap-multiselect-dropdown/#forms显示带有多个复选框的下拉列表.
<li>
<label>
<input type="checkbox" name="filters" value="first value">
<span>First Value</span>
</label>
</li>
<li>
<label>
<input type="checkbox" name="filters" value="second value">
<span>Second Value</span>
</label>
</li>
Run Code Online (Sandbox Code Playgroud)
这是结果URL:
http://example.com/search?filters=first+value&filters=second+value
Run Code Online (Sandbox Code Playgroud)
在服务器端(瓶子):
terms = unicode (request.query.get ('filters', ''), "utf-8")
Run Code Online (Sandbox Code Playgroud)
只会给我"第二价值"并忽略"第一价值".有没有办法收集所有'过滤器'值?
我创建了一个简单的函数来执行 Http PUT 请求 -
public string checkIfUserExists(string userName)
{
var endPoint = new Uri("http://localhost:8080/jasperserver/rest_v2/users/"+userName);
var request = (HttpWebRequest)WebRequest.Create(endPoint);
request.Method = "PUT";
request.ContentType = "urlencoded";
var response = (HttpWebResponse)request.GetResponse();
return "Success";
}
Run Code Online (Sandbox Code Playgroud)
当我执行此操作时,我在该行收到异常“无效的 URI:指定的端口无效” -
var endPoint = new Uri("http://localhost:8080/jasperserver/rest_v2/users/"+userName);
Run Code Online (Sandbox Code Playgroud)
有解决这个问题的想法吗?URL 的 localhost:8080 部分有问题吗?
何时使用RequestHandler.get_argument(),RequestHandler.get_query_argument()和RequestHandler.get_body_argument()?
每个人的用例是什么?
在这些情况下request.body,request.argument做什么和做什么?在哪些场景中使用哪些?
而且,是否还有request.query类似的东西呢?
是否可以检测是否通过代理服务器发出传入请求?如果Web应用程序通过IP地址"禁止"用户,他们可以通过使用代理服务器来绕过这一点.这只是阻止这些请求的一个原因.怎么能实现这一目标?
我想使用此Google API(仅用于测试):
https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US
我的问题是:我应该如何向此URL发送POST请求?我正在使用:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *recDir = [paths objectAtIndex:0];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/recordTest.flac", recDir]];
NSData *myData = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/recordTest.flac", recDir]];
//NSString *audio = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/recordTest.flac", recDir]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:[NSURL
URLWithString:@"https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US"]];
[request setHTTPMethod:@"POST"];
//set headers
[request addValue:@"Content-Type" forHTTPHeaderField:@"audio/x-flac; rate=16000"];
[request addValue:@"audio/x-flac; rate=16000" forHTTPHeaderField:@"Content-Type"];
NSString *requestBody = [[NSString alloc] initWithFormat:@"Content=%@", myData];
[request setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]];
[request setValue:[NSString stringWithFormat:@"%d",[myData length]] forHTTPHeaderField:@"Content-length"];
NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init]; …Run Code Online (Sandbox Code Playgroud) 我正在尝试发帖,但是每次我发帖时,都会收到 411 响应错误。我在 python 中使用请求库。
In [1]: r.post(url)
Out[1]: <Response [411]>
Run Code Online (Sandbox Code Playgroud)
然后我指定了内容长度h = {'content-length' : '0'}并重试。
In [2]: r.post(url,h)
Out[2]: <Response [200]>
Run Code Online (Sandbox Code Playgroud)
太好了,我成功了,但是没有发布任何信息。
我想我需要计算内容长度,这是有道理的,因为它可能会“切断”帖子。
所以我的问题是,给定一个网址www.example.com/import.php?key=value&key=value,我该如何计算content-length?(如果可能,在 python 中)
我试图通过从后台线程同步运行它来使[NSString stringWithContentsOfURL:encoding:error:]异步:
__block NSString *result;
dispatch_queue_t currentQueue = dispatch_get_current_queue();
void (^doneBlock)(void) = ^{
printf("done! %s",[result UTF8String]);
};
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(unsigned long)NULL), ^(void) {
result = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/"] encoding:NSUTF8StringEncoding error:nil];
dispatch_sync(currentQueue, ^{
doneBlock();
});
});
Run Code Online (Sandbox Code Playgroud)
它的工作正常,最重要的是,它的异步.
我的问题是这样做是否安全,或者是否存在任何线程问题等?
提前致谢 :)
我想知道我们是否可以使用node.js来衡量完成http请求所需的时间.从文档(这里)稍微修改一个例子,可以很容易地写下以下代码.
var http = require('http');
var stamp1 = new Date();
var stamp2, stamp3, stamp4;
var options = {
hostname: 'www.google.com',
port: 80,
path: '/upload',
method: 'POST'
};
var req = http.request(options, function(res) {
stamp3 = new Date();
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
res.on('end', function () {
stamp4 = new Date();
console.log ("Stamp 3: " + stamp3);
console.log ("Stamp 4: " + stamp4);
});
});
req.on('error', …Run Code Online (Sandbox Code Playgroud)我是Web Dev,Meteor以及所有REST的新手,但我正在尝试编写一个服务器端方法,向第三方服务器发出Meteor http post请求,并将图像上传到它.我无法正确设置它.我想在multipart/form-data部分的主体中上传文件,但是我无法生成正确的请求...
这就是我所拥有的:
Meteor.methods({
postOCR:function(newFile){
var options = {
headers: {'secret': mySecret,
'Content-Type': 'multipart/form-data'},
data: {'Content-Disposition': 'form-data',
'name':'image',
'filename':newFile
}
}
HTTP.call('POST', url, options, function(error, result) {
if (error) {
console.log('ERRR');
console.log(error);
} else
console.log('RESULT');
console.log(result);
});
}
});
Run Code Online (Sandbox Code Playgroud)
这是我想要建立的请求:
POST /some/res HTTP/1.1
Host: myUrl
secret: mySecret
Cache-Control: no-cache
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="multipart/form-data"; filename="img.jpg"
Content-Type: image/jpeg
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Run Code Online (Sandbox Code Playgroud)
初始请求正常,但我似乎没有正确上传文件...任何人都可以告诉我我做错了什么?
谢谢!
我在Elastic Load Balancer后面有一个AWS Elastic Beanstalk(Node.js)设置,并为负载均衡器设置警报.每天晚上我收到大量警报:
Environment health has transitioned from Ok to Severe. 100.0 % of the requests are erroring with HTTP 4xx.
这是由于在99%的情况下使用HEAD方法拖网不同的PHP hackz和phpmyadmin,dbadmin等.由于我们有一个外部AIM服务,他们会触发这些警报以及为每个警报创建一个问题(我们现在改变了)但是你知道哭泣的"狼"......
问题是,是否可以阻止HEAD或某些URI我们知道我们不需要以某种方式摆脱"假"HTTP 4xx?
http amazon-ec2 amazon-web-services http-headers http-request
http-request ×10
http-headers ×3
python ×3
http ×2
objective-c ×2
amazon-ec2 ×1
asp.net ×1
asynchronous ×1
bottle ×1
c# ×1
httpresponse ×1
ios ×1
javascript ×1
meteor ×1
node.js ×1
post ×1
proxy ×1
timing ×1
tornado ×1