本文将带您了解关于如何使用PHP/apache访问原始的HTTP请求数据?的新内容,同时我们还将为您解释php访问api的相关知识,另外,我们还将为您提供关于Apache–如何使http请求变成只有h
本文将带您了解关于如何使用PHP / apache访问原始的HTTP请求数据?的新内容,同时我们还将为您解释php访问api的相关知识,另外,我们还将为您提供关于Apache – 如何使http请求变成只有https?、Http请求数据格式、java – 使用Apache HttpComponents客户端签署AWS HTTP请求、java – 使用org.apache.http发送带有SOAP操作的HTTP Post请求的实用信息。
本文目录一览:- 如何使用PHP / apache访问原始的HTTP请求数据?(php访问api)
- Apache – 如何使http请求变成只有https?
- Http请求数据格式
- java – 使用Apache HttpComponents客户端签署AWS HTTP请求
- java – 使用org.apache.http发送带有SOAP操作的HTTP Post请求
如何使用PHP / apache访问原始的HTTP请求数据?(php访问api)
我想知道是否有一种方法可以在Apache上运行PHP中的原始HTTP请求数据,而不需要使用任何额外的扩展。 我已经在手册中看到了HTTPfunction,但是我没有在我的环境中安装扩展的选项。
虽然我可以从$ _SERVER访问信息,但我希望看到原始请求与发送到服务器的原始请求完全一致。 PHP使用标题名称来适应自己的数组键的风格,例如。 Some-Test-Header成为HTTP_X_SOME_TEST_HEADER。 这不是我所需要的。
htaccess将所有页面redirect到单个页面
PHP输出缓冲区不冲洗
在Windows下Django syncdb错误(OpenKey错误?)
为什么下划线在HTTP标头名称中是被禁止的
通过multipartentity发送Unicode字符
你是指$_SERVER包含的信息吗?
print_r($_SERVER);
编辑:
那会这样吗?
foreach(getallheaders() as $key=>$value) { print $key.'': ''.$value."<br />"; }
使用下面的PHP包装器:
$raw_post = file_get_contents("PHP://input");
尝试这个:
$request = $_SERVER[''SERVER_PROTOCOL''] .'' ''. $_SERVER[''REQUEST_METHOD''] .'' ''. $_SERVER[''REQUEST_URI''] . PHP_EOL; foreach (getallheaders() as $key => $value) { $request .= trim($key) .'': ''. trim($value) . PHP_EOL; } $request .= PHP_EOL . file_get_contents(''PHP://input''); echo $request;
我使用修剪,因为有一些无效的字节字符尾随头$键。
总结
以上是小编为你收集整理的如何使用PHP / apache访问原始的HTTP请求数据?全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
Apache – 如何使http请求变成只有https?
如何判断用户是否使用http://ttt.com或http://www.ttt.com ,将其redirect到https://www.ttt.com ?
httpd.conf中:
<VirtualHost *:80> ServerName www.ttt.com ServerAlias ttt.com DocumentRoot /home/www/html/ttt/public <Directory /home/www/html/ttt/public> #Options ExecCGI #AddDefaultCharset utf-8 DirectoryIndex index.PHP AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
.htaccess:
RewriteEngine On ############################################ ## always send 404 on missing files in these folders #RewriteCond %{REQUEST_URI} !^/(files)/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.PHP [NC,L]
使用Apache在PHP上创build一个带有2个参数的友好URL
利用第三方JS的浏览器caching
有条件的DirectoryIndex在.htaccess中
.htaccess更改需要多长时间才能生效?
.htaccess图像URL的RewriteRule
我怎样才能设置CORS访问我的Linux Web服务器上的audio文件与Apache2?
如何在1and1共享主机上configurationCake 2.3.x的htaccess文件
redirect规则与特殊字符
MysqL + htaccess的mod_rewrite?
.htaccess – 重写查询string并redirect到目录
在主目录.htaccess文件中尝试以下代码:
DirectoryIndex index.PHP RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
你可以用httpd.conf来做到这一点:
<VirtualHost *:80> serverName www.ttt.com Redirect "/" "https://www.ttt.com/" </VirtualHost> <VirtualHost *:443> serverName www.ttt.com ... ... </VirtualHost>
或从.htaccess文件中:
RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
这里你去: https : //wiki.apache.org/httpd/RedirectSSL
将请求重定向到SSL
假设您希望http://www.example.com/secure/始终通过SSL发送(我在这里假定普通和SSL虚拟主机都具有相同的内容)。 你可以通过链接到你的HTML页面中的正确页面来做到这一点…但总是会有一些用户以这种方式潜入。
使用虚拟主机(使用重定向)
使用SSL时,您至少需要两台虚拟主机:一台用于端口80,用于提供普通请求,另一台用于端口443以提供SSL。 如果您希望将用户从非安全站点重定向到SSL站点,则可以在不安全的VirtualHost内使用普通的Redirect指令:
NameVirtualHost *:80 <VirtualHost *:80> serverName mysite.example.com DocumentRoot /usr/local/apache2/htdocs Redirect permanent /secure https://mysite.example.com/secure </VirtualHost> <VirtualHost _default_:443> serverName mysite.example.com DocumentRoot /usr/local/apache2/htdocs SSLEngine On # etc... </VirtualHost>
当重定向你甚至不需要DocumentRoot的时候:
NameVirtualHost *:80 <VirtualHost *:80> serverName www.example.com Redirect permanent / https://secure.example.com/ </VirtualHost> <VirtualHost _default_:443> serverName secure.example.com DocumentRoot /usr/local/apache2/htdocs SSLEngine On # etc... </VirtualHost>
注意 :重定向也可以在.htaccess文件中使用,或者用于处理特定的URL,如下所示:
例:
重定向永久/登录https://mysite.example.com/login
使用mod_rewrite
虽然建议使用这个解决方案,因为它更简单,更安全,但也可以使用mod_rewrite获得与此处所述相同的效果: RewriteHTTPToHTTPS
从https://httpd.apache.org/docs/trunk/mod/mod_alias.html#redirect :
# Redirect to a URL on a different host Redirect "/service" "http://foo2.example.com/service" # Redirect to a URL on the same host Redirect "/one" "/two"
如果客户端请求http://example.com/service/foo.txt ,则会被告知访问http://foo2.example.com/service/foo.txt 。 这包括使用GET参数的请求,例如http://example.com/service/foo.pl?q=23&a=42 ,它将被重定向到http://foo2.example.com/service/foo.pl? q = 23&a = 42 。 请注意,POST将被丢弃。 只有完整的路径段被匹配,所以上面的例子不匹配http://example.com/servicefoo.txt的请求。 要使用表达式语法进行更复杂的匹配,请按照下面的说明省略URL路径参数。 或者,对于使用正则表达式进行匹配,请参阅RedirectMatch指令。
如果您希望将www.example.com/*和example.com/*重定向,则可以使用不同的serverName创建两个VirtualHost,或者使用Rewrite插件。
总结
以上是小编为你收集整理的Apache – 如何使http请求变成只有https?全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
Http请求数据格式
-
Content-Type
,内容类型,一般是指网页中存在的Content-Type
,用于定义网络文件的类型和网页的编码,用来在程序间传送内容相关的编码信息,数据类型信息,前端以何种数据格式传递给后端。 -
Accept
,代表发送端(客户端)希望接受的数据类型。 -
Http content-Type
有很多种,点击查看,这里看集中常见的类型。
1.application/x-www-form-urlencoded
-
最常见的请求格式,原生
form
表单请求结构,以键值对的形式传递默认会以这种方式;提交的数据按照key1=val1&key2=val2
的方式进行编码,key
和val
都进行了URL
转码。大部分服务端语言都对这种方式有很好的支持Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Content-Type:application/x-www-form-urlencoded Form Data first_name=i&last_name=i
2.multipart/form-data
-
常见的
POST
数据提交的方式。这种方式一般用来上传文件,各大服务端语言对它也有着良好的支持。一般会生成了一个boundary
用于分割不同的字段,为了避免与正文内容重复,boundary
很长很复杂。然后Content-Type
里指明了数据是以mutipart/form-data
来编码,本次请求的boundary
是什么内容。消息主体里按照字段个数又分为多个结构类似的部分,每部分都是以--boundary
开始,紧接着内容描述信息,然后是回车,最后是字段具体内容(文本或二进制)。如果传输的是文件,还要包含文件名和文件类型信息。消息主体最后以--boundary--
标示结束Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="key" value ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="testKey" testValue ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="imgFile"; filename="no-file" Content-Type: application/octet-stream <data in here> ------WebKitFormBoundary7MA4YWxkTrZu0gW--
3.application/json
-
现在以JSON格式作为请求头越来越主流。
Accept:application/json, text/plain, */* Content-Type:application/json;charset=UTF-8 Request payLoad {name: "m", password: "hkkk", email: "123"}
java – 使用Apache HttpComponents客户端签署AWS HTTP请求
我使用 Jest,反过来使用 Apache HttpComponents Client.
这似乎是一个常见的用例,我想知道是否有一些类型的库,我可以使用Apache HttpComponents客户端来签名所有的请求.
解决方法
总结
以上是小编为你收集整理的java – 使用Apache HttpComponents客户端签署AWS HTTP请求全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
java – 使用org.apache.http发送带有SOAP操作的HTTP Post请求
@H_301_0@我的问题是没有找到一种方法来添加请求正文(在我的例子中是SOAP操作).
我会很高兴有一些指导.
import java.net.URI; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.RequestWrapper; import org.apache.http.protocol.HTTP; public class HTTPRequest { @SuppressWarnings("unused") public HTTPRequest() { try { HttpClient httpclient = new DefaultHttpClient(); String body="DataDataData"; String bodyLength=new Integer(body.length()).toString(); System.out.println(bodyLength); // StringEntity stringEntity=new StringEntity(body); URI uri=new URI("SOMEURL?Param1=1234&Param2=abcd"); HttpPost httpPost = new HttpPost(uri); httpPost.addHeader("Test","Test_Value"); // httpPost.setEntity(stringEntity); StringEntity entity = new StringEntity(body,"text/xml",HTTP.DEFAULT_CONTENT_CHARSET); httpPost.setEntity(entity); RequestWrapper requestWrapper=new RequestWrapper(httpPost); requestWrapper.setMethod("POST"); requestWrapper.setHeader("LuckyNumber","77"); requestWrapper.removeHeaders("Host"); requestWrapper.setHeader("Host","GOD_IS_A_DJ"); // requestWrapper.setHeader("Content-Length",bodyLength); HttpResponse response = httpclient.execute(requestWrapper); } catch (Exception e) { e.printstacktrace(); } } }
解决方法
看看这里一个例子与apache httpclient:http://svn.apache.org/repos/asf/httpcomponents/oac.hc3x/trunk/src/examples/PostSOAP.java
关于如何使用PHP / apache访问原始的HTTP请求数据?和php访问api的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Apache – 如何使http请求变成只有https?、Http请求数据格式、java – 使用Apache HttpComponents客户端签署AWS HTTP请求、java – 使用org.apache.http发送带有SOAP操作的HTTP Post请求的相关知识,请在本站寻找。
本文标签: