我想使用webview发出http发布请求.
webView.setWebViewClient(new WebViewClient(){
public void onPageStarted(WebView view, String url,
Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
public boolean shouldOverrideUrlLoading(WebView view,
String url) {
webView.postUrl(Base_Url, postData.getBytes());
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
上面的代码段加载了网页.我想访问此请求的响应.
如何使用webview获取http post请求的响应?
提前致谢
我刚刚在Ebay上购买了新的ENC28J60以太网LAN网络模块,我想将此模块的POST数据发送到指定的网址,例如.www.mydomain.com/example.php
我重新阅读了谷歌的一些例子,但我能看到的只是arduino盾牌的例子,而不是我的模块.有了这个模块,我正在使用以下库:
"etherShield.h"
"ETHER_28J60.h"
我想将一个/两个指定的POSTS(变量)发送到php公式,但我不知道如何做到这一点.
所以我有一个像这样的控制器:
public class TestController : Controller
{
//
// GET: /Test/
public ActionResult Index()
{
return View("Test");
}
public ActionResult Post(IList<Test> LanguageStrings, IList<Test> LanguageStringsGroup, IList<string> Deleted, IList<string> DeletedGroup)
{
if (LanguageStrings == null)
{
throw new ApplicationException("NULL");
}
return View("Test");
}
}
public class Test
{
public string Val { get; set; }
public string Another { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这样的观点:
<h2>Test</h2>
@using (Html.BeginForm("Post", "Test"))
{
@Html.Hidden("LanguageStrings[0].Val", "test1")
@Html.Hidden("LanguageStrings[0].Another")
@Html.Hidden("LanguageStrings[1].Val", "test2")
@Html.Hidden("LanguageStrings[1].Another")
@Html.Hidden("LanguageStringsGroup[0].Val", "test4")
@Html.Hidden("Deleted[0]")
@Html.Hidden("Deleted[1]")
@Html.Hidden("Deleted[2]")
@Html.Hidden("DeletedGroup[0]")
<button>Post</button> …Run Code Online (Sandbox Code Playgroud) 我想循环发送帖子请求.如果我连续发送2个请求,那么只有最后一个请求真正进行了回调.
我做错了什么?
this.assignAUnits = function(){
var currentIncidentId = this.incident.incidentId;
for (var i=0; i< this.selectedAvailableUnits.length; i++){
var unit = this.selectedAvailableUnits[i];
var unitId = unit.unitId;
var url = '/incident/' + currentIncidentId + '/assignUnit/' + unitId
$http.post(url).then(function(response) {
DOING SOMETHING
}, function(error) {
alert(error);
});
}
};
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个简单的webhook来接收来自Nexmo SMS服务的送货回执.他们网站上唯一的文件就是这个.
During account set-up, you will be asked to supply Nexmo a CallBack URL for Delivery Receipt to which we will send a delivery receipt for each of your SMS submissions. This will confirm whether your message reached the recipient's handset. The request parameters are sent via a GET (default) to your Callback URL and Nexmo will be expecting response 200 OK response, or it will keep retrying until the Delivery Receipt expires (up to 72 hours).
我一直在寻找这样做的方法,到目前为止,我从网上找到的一个例子中得到了这个方法,虽然我不确定这是否正确.无论如何,这是在ASP.NET和端口6563上运行,所以这是我应该听的端口吗?我下载了一个名为ngrok的应用程序,它应该将我的本地Web服务器暴露给互联网,所以我运行了应用程序并指示它监听端口6563,但没有运气.我一直在试图找到一些帖子来发布这个功能.
[HttpPost] …Run Code Online (Sandbox Code Playgroud) 假设这是请求的有效负载:
{name : 'John', age: 42}
Run Code Online (Sandbox Code Playgroud)
你可以得到所有的参数Request::all().
如何获取请求负载correctyly如果有效载荷是一个原始类型像true或42?
Request::getContent() 接收它们作为字符串,我希望它们也是正确的类型.
我正在制作一个 chrome 扩展,我有一个 popup.html 页面,其中包含一个带有方法帖子的表单,当使用弹出按钮打开时它不会做任何事情但是如果页面作为选项页面或只是一个普通的 html 页面打开,表单发布正常,新页面已加载。
所以弹出窗口中的某些内容阻止了表单工作。
我不知道为什么,有人知道如何解决/解决这个问题吗?
是否有在原生 php 语言中定义的“GET”、“POST”等常量,我已经尝试过:
HTTP_METH_GET
Run Code Online (Sandbox Code Playgroud)
等,
但没有成功
我正在尝试将表单变量添加到 Go http 请求中。
这是我的 Go 测试的样子:
func sample_test(t *testing.T) {
handler := &my_listener_class{}
reader := strings.NewReader("number=2")
req, _ := http.NewRequest("POST", "/my_url", reader)
w := httptest.NewRecorder()
handler.function_to_test(w, req)
if w.Code != http.StatusOK {
t.Errorf("Home page didn't return %v", http.StatusOK)
}
}
Run Code Online (Sandbox Code Playgroud)
问题是表单数据永远不会传递给我需要测试的函数。
另一个相关函数是:
func (listener *my_listener_class) function_to_test(writer http.ResponseWriter, request *http.Request) {
...
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Go 版本 go1.3.3 darwin/amd64。
我正在使用HttpClient.PostAsync()我的 Windows Phone 8 应用上传图像。用户可以选择通过 UI 按钮取消此上传。
为了取消 POST 请求,我设置了一个CancellationToken. 但这不起作用。在取消请求之后,我仍然看到在我的代理中进行了上传,很明显该请求被忽略了。我的代码:
using (var content = new MultipartFormDataContent())
{
var file = new StreamContent(stream);
file .Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
FileName = "filename.jpg",
};
file.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
content.Add(file);
await httpclient.PostAsync(new Uri("myurl", UriKind.Absolute), content,
cancellationToken);
}
Run Code Online (Sandbox Code Playgroud)
另请注意,我有一CancellationTokenSource对CancellationToken。在用户点击取消按钮后,tokensource.Cancel()被调用。此外,我的测试用例中的图像从 1 到 2 MB(不是那么大)。
那么,有没有办法取消HttpClientPOST 请求?
http-post ×10
asp.net-mvc ×2
c# ×2
android ×1
angularjs ×1
arduino ×1
c ×1
callback ×1
cancellation ×1
constants ×1
ethernet ×1
for-loop ×1
forms ×1
go ×1
http-get ×1
httpclient ×1
httprequest ×1
javascript ×1
json ×1
laravel ×1
laravel-5 ×1
list ×1
php ×1
popup ×1
request ×1
response ×1
testing ×1
unit-testing ×1
webhooks ×1
webview ×1