Home > Backend Development > PHP Tutorial > Get request method using other encoded parameters

Get request method using other encoded parameters

小云云
Release: 2023-03-20 13:22:01
Original
1698 people have browsed it

I encountered a problem when sending a small program for parameter reading results to the website. The website uses the get method to transmit the query parameters, but when I send parameter query results according to the format of the website, the result is always empty. I found it using fiddle to capture the packet. The parameters sent by the website are not UTF-8 encoded URLENCODE, but GBK encoded characters are sent directly to the server. After searching for a long time, I couldn't find a solution. I found a very useful article for reference and clicked to open the link. I slightly changed the way to send the request and the solution was solved. I recorded it myself.

http requests are essentially sending byte streams, so sockets can be used instead of httpwebrequest\response in c# to implement:

Send request:

public void SendRequest(string server,string requestString,Encoding e){
Uri u= new Uri(server);
Socket s=new Socket(AddressFamily.InternetNetwork, SocketType.Stream, ProtocolType.Tcp);
s.SendTimeout=3000;
s.ReceiveTimeout=3000;
s.Connect(u.Host,u.Port);
if(s.Connected)    {
s.Send(e.GetBytes(s),SocketFlags.None);
System.Threding.Thread.Sleep(1000);//等待1秒确保数据发送完成,我的请求比较简单,复杂的也可以判断数据发送完成再处理。。。
Copy after login

Process the received You can refer to the article mentioned above for part of it, mainly because the reception and processing of chunked data requires special processing.

Related recommendations:

Problems with special symbols in get requests

Example tutorials on get requests

WeChat applet network request (GET request) detailed description

The above is the detailed content of Get request method using other encoded parameters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template