我想使用pear http_request2($ url)类发出https请求.我能够发出http请求但不能https.并且该网站便于http和https.服务器响应https没有问题.
require 'HTTP/Request2.php';
$url = 'https://collegedb2.ferryfair.com';
$r = new Http_Request2($url);
$r->setMethod(HTTP_Request2::METHOD_POST);
try {
$response = $r->send();
} catch (Exception $exc) {
$es = $exc->getTraceAsString();
$ets=$exc->__toString();
$egc=$exc->getCode();
$egl=$exc->getLine();
$egm=$exc->getMessage();
$egt=$exc->getTrace();
$response = null;
}
$page = $response->getBody();
echo $page;
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
$egm=(string) Unable to connect to ssl://collegedb2.ferryfair.com:443. Error: stream_socket_client(): unable to connect to ssl://collegedb2.ferryfair.com:443 (Unknown error)
好吧,这是交易,我编写了一个应用程序,通过HTTP(post)数据从web url请求,数据使用JSon数组返回,我解析这些数组,以获得我想要的.
直到那里使用Android 2.3.x没有问题但是当我在Android 4中测试它时它根本不起作用.
这是我的代码:
public boolean testConexio(){
boolean status = false;
String rutaServer = "URL.php";
//Log.e("log_tag", "Ruta server: "+rutaServer);
InputStream is = null;
String result = "";
String temporal;
//Valors a demanar/enviar
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("param1",config.getUserDB())); // parametros POST!
nameValuePairs.add(new BasicNameValuePair("param2",config.getPassDB())); // parametros POST!
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(rutaServer);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8")); // valors POST UTF 8 coded <-- I KNOW! this is the way i need them …Run Code Online (Sandbox Code Playgroud) android http-post http-request android-4.0-ice-cream-sandwich
我有一个抛出null异常的HTTP请求.
这是代码:
public String updateRounds() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx");
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("Username", _user));
nameValuePairs.add(new BasicNameValuePair("Password", _password));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = "";
// Execute HTTP Post Request
try {
response = httpclient.execute(httppost, responseHandler); // it gets …Run Code Online (Sandbox Code Playgroud) 对于不是由HTML表单发送的请求,HTTP是否将请求的Content-Type限制为application/x-www-form-urlencoded以用于非文件上载,或者是MIME类型"right"/标准/语义在任何其他方面有意义办法?
例如,PHP会自动将内容解析为$ _POST,这似乎表明服务器需要x-www-form-urlencoded.另一方面,我可以使用Ajax在HTTP请求内容中发送JSON对象,并将Content-Type设置为application/json.至少一些服务器技术(例如WSGI)不会尝试解析它,而是以原始形式向脚本提供它.
我应该在RESTful API中的POST和PUT请求中使用什么MIME类型来确保符合HTTP的所有服务器实现?我忽略了SOAP和JSON-RPC等技术,因为它们通过HTTP隧道传输协议而不是按预期使用HTTP.
关于在stackoverflow上访问HttpRequest有很多问题,但是我还没找到一个我可以使用的.如果有人能指出我的答案,我将不胜感激.
我的问题是我想以最简单的方式修改现有的应用程序,以便添加完整的请求记录.我知道这可以通过Http模块和IIS日志记录或使用Log4net等来完成.但我不想使用任何这些技术,因为应用程序是不可预测的,所以我需要一个不需要任何配置更改的解决方案一点都不
我已将OnActionExecuted添加到基本控制器.
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
// todo: log request from filter context ....
base.OnActionExecuted(filterContext);
}
Run Code Online (Sandbox Code Playgroud)
在上面的"todo"部分中,我希望阅读原始http请求并将其保存到数据库文件中.记录到数据库很简单,但序列化或以其他方式将http请求转换为字符串的最佳方法是什么?
谢谢
这是我的问题; 我想从URL获取一些数据,这是代码:
let internetURL = NSURL(string:"http://www.example.org")
let siteURL = NSURLRequest(URL: internetURL!)
let siteData = NSURLConnection(request: siteURL, delegate: nil, startImmediately: true)
let strSiteData = NSString(data: siteData, encoding: NSUTF8StringEncoding)
Run Code Online (Sandbox Code Playgroud)
当我写这个,XCode给我以下错误:
在调用中额外参数'encoding'
在最后一行.我能怎么做?
我想用一个带有zip文件的http PUT请求以二进制形式发送到web api并获得带有http状态代码的响应.
如何读取文件并将其与二进制文件一起使用?
谢谢您的帮助!!
在Laravel 5.2,我添加了我的事件监听器(入app\Providers\EventServiceProvider.php),如:
protected $listen = [
'Illuminate\Auth\Events\Login' => ['App\Listeners\UserLoggedIn'],
];
Run Code Online (Sandbox Code Playgroud)
然后生成它:
php artisan event:generate
Run Code Online (Sandbox Code Playgroud)
然后在Event Listener文件中app/Listeners/UserLoggedIn.php,它就像:
<?php
namespace App\Listeners;
use App\Listeners\Request;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Auth\Events\Login;
class UserLoggedIn
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
}
/**
* Handle the event.
*
* @param Login $event
* @return void
*/
public function handle(Login $event, Request $request)
{
$request->session()->put('test', 'hello world!');
}
}
Run Code Online (Sandbox Code Playgroud)
这告诉我以下错误:
ErrorException …Run Code Online (Sandbox Code Playgroud) 我在循环中发出HTTP请求时遇到了一些麻烦.
让我解释一下我的内容......
我创建一个http GET来检索一些值,然后我需要为我刚刚从第一个请求获取的每个值创建另一个HTTP GET.
两个调用for都没问题,如果我切断循环并尝试运行整个请求链,它就可以完美地工作,但是自从我删除循环后只有一次.我怎样才能使它工作?
这是代码:
request({
url: "some_url",
method: "GET",
json:true,
headers:[{'content-type': 'application/json'}]
}, function (error, response, body){
if(!error & response.statusCode === 200){
for(var i=0;i<body.length;i++){
for(var j=i;j<body.length-1;j++){
//if(i === body.length-1) return;
src = body[i].name;
dest = body[j+1].name;
console.log("sorgente ",sorg);
request({
url: "https://maps.googleapis.com/maps/api/distancematrix/json?origins="+src+"&destinations="+dest,
method: "POST",
json:true,
headers:[{'content-type': 'application/json'}]
}, function (error, response, body){
if(!error & response.statusCode === 200){
console.log("TIME ",body.rows[0].elements[0].duration.text);
return;
}else{
console.log("google API failed!: ");
return;
}
});
}
}
}else{
console.log("/google_api failed!: ");
return;
} …Run Code Online (Sandbox Code Playgroud) 我有 apache 作为 http 服务器和 php,我从浏览器向这个具有 for 循环的 php 脚本发送了大约 5 个并发请求,这需要很长时间才能完成,我看到所有并发请求都被阻止并按顺序提供。
如何为 http 请求服务的非阻塞行为而不是顺序服务行为配置 apache 或 php?
I know that Tomcat server http connector can tune using following server parameters
– Threads (maxThreads)
– Keep alive requests (maxKeepAliveRequests)
– TCP Backlog (acceptCount)
– connectionTimeout
– Socket buffers
- Use different connectors (nio, apr, bio)
etc...
Run Code Online (Sandbox Code Playgroud)
针对 5 个并发请求进行测试的 php 代码片段,但由 Web 服务器(apache 2.2、php 5.3)按顺序提供
<?php
for ($i = 1; $i < 500000; $i++) { //do some processing which takes …Run Code Online (Sandbox Code Playgroud) http-request ×10
android ×2
http ×2
node.js ×2
php ×2
android-4.0-ice-cream-sandwich ×1
apache ×1
asp.net-mvc ×1
c# ×1
http-headers ×1
http-post ×1
https ×1
ios ×1
javascript ×1
laravel ×1
laravel-5.2 ×1
nonblocking ×1
pear ×1
post ×1
put ×1
session ×1
swift ×1