requests and responses for HTTP Protocols
first, about the HTTP protocol
1.HTTP (Hypertext Transport Protocol), which is the Hypertext Transfer Protocol.
This protocol details the rules for communicating with each other between the browser and the World Wide Web server.
2. What is transmitted when the client communicates with the server is what we call a message.
3.HTTP is a communication rule that specifies the message format that the clie
Original: http://www.cnblogs.com/z941030/p/4699779.htmlThe HTTP protocol specifies the request format issued by the browser and the response format issued by the Web server.The request part consists of three parts:
RequsetLine: Request lines, on the first line
Request Headers: Requests message header, starting from the second line to the end of the f
the properties associated with the connection, such as Connection:keep-alive
Accept-charset
Notifies the service side of the encoding format that can be sent
Accept-encoding
Notifies the server that a data compression format can be sent
Accept-language
Notifies the server which languages can be sent
There is a blank line at the end of t
Yii2 framework RESTful API format response, authorization authentication, and rate limit
I have previously written a quick start tutorial on creating RESTful APIs in the Yii2 framework. Today I want to explore the format response, authorization authentication, and Rate limiting of Yii2 RESTful APIs.
I. directory struct
Before writing a YII2 framework to create a restful-style API QuickStart tutorial, go on to explore YII2 RESTful's formatted response, authorization certification and rate limiting three parts
First, directory structure
List the files you want to change first. The directory is as follows:
Web
├─common
│└─models
│└user.php
└─frontend
├─config
│└main.php />└bookcontroller.php
Second, formatted respon
present. getMenuInflater (). inflate (R. menu. main, menu); return true ;}@ Override public boolean onOptionsItemSelected (MenuItem item) {// Handle action bar item clicks here. the action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent
ActivityIn
AndroidManifest. xml. Int id = item. getItemId (); if (id = R. id. action_settings) {return true;} return super. onOptionsItemSelected (item );}}
The following is a server-side
In Yii2, if you set the' Response ' = [' Format ' = Yii\web\response::format_json,' CharSet ' = ' UTF-8 ',// ...],Represents, the controller output is all JSON format data, that is, JSON string;And if the use of Json::htmlencode ($price);First, the use Yii\helpers\json is introduced;A JSON string can be generated in th
application/x-www-form-urlencoded Multipart/form-data Text/plainWhy add a property to the form that uploads the file enctype the format type of the data response returned by the backgroundUpload a file in the form ①application/x-www-form-urlencoded (default value)②multipart/form-data③text/plainWhere ①application/x-www-form-urlencoded is the default value, you may have seen this in Ajax: Xmlhttp.setrequesthe
This article describes the Angularjs ng Http request and the response format conversion method. Share to everyone for your reference, specific as follows:
The interactive approach recommended by angular as a single Page application is of course based on JSON Ajax calls. But what I'm saying today is that when you're unlucky enough to work on a legacy or uncontrollable service that is based on non-JSON submi
to run things locally:Where on the Nodejs server:1, open the cmd window, move to the relevant directory, here to E disk for example:2, Installation Http-serverUse the command to install NPM install HTTP-server -g -G: For global installation, install to C:\Users\ user name \appdata\roaming\npm\node_modules If it is only used under the directory, you can move to the relevant directory using npm install HTTP-Server Installation 3. After successful installation, enter Http-serverThe default
http/1.1 $Ok\r\nset-COOKIE:FSM_LOGIN=21232F297A57A5A743894A0E4A801FC3; path=/\r\ncontent-type:application/json\r\ncontent-length: the\r\n\r\n{"Hwid":"6cda2df5b71cf8d3d24515fd308a7b73","type":"hs-30r","mac":"000c43220060"}http/1.1 OK: Response code, according to the response code, the browser to make the corresponding actionSet-cookie: Set cookies, browser settings automaticallyContent-type: Data type, JSON
1 RequirementsAfter each request succeeds, the response format returned by the background is consistent, for example: 2 Creating a View modelThe model is used to format the response data Package Cn.xiangxu.springboottest.model.dataViewModel; Import Lombok. Data; @Datapublicclass resultviewmodel { private Integer
/xml;charset=utf-8 ');
/ * Request Response content format when transferring data in XML format is text/xml*/
/*file_get_contents Get File contents * /
$xml = file_get_contents (' 01.xml ');
/ * Output XML content * /
echo $xml;
?>
3. AjaxHow to get the response data in XML format:Respon
First, what is the HTTP protocol?Reprint: http://blog.csdn.net/daijin888888/article/details/51025634A Network application layer protocol developed by the Web user, which defines the process of communication between the browser and the server and the data format used in the communication.1) The process of communicationStep1, the browser establishes a connection to the Web serverStep2, the browser packages the request data (generates a request packet) a
detection logic. this information is defined by your browser and is automatically sent in each request. connection, usually set the browser operation to keep-alivePart 3: Empty rows. This empty row is required even if the request body does not exist.
Example 2 POST request:
Post/http1.1HOST: www.wrox.comUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; sv1;. Net CLR 2.0.50727;. Net CLR 3.0.04506.648;. Net CLR 3.5.21022)Content-Type: Application/X-WWW-form-urlencodedCon
chunk-size chunk-data, skip CRLFAppend Chunk-data to entity-body // append this chunk-data block to entity-bodyRead chunk-size and CRLF // read the chunk-size and CRLF of the new chunk}The format of read entity-header // entity-header is name: valuecrlf. If it is null, only CRLFWhile (entity-header not empty) // that is, it is not a blank line with only CRLF{Append entity-header to existing header fieldsRead entity-Header}Content-Length: = length //
1. modify configuration file jmeter. properties line 974th, default encoding format for ISO-8859-1, manual modification to UTF-82. Add ComponentsRight-click the thread group and choose "add"> "postprocessor"> "beanshell postprocessor ".After the script is added, enter the following code in the script column:Prev. setdataencoding ("UTF-8 ");Both methods can solve Chinese garbled characters.Jmeter sets the encoding
;document.getElementById (' Test '). InnerHTML = str;}
The final task is to generate the buttons that call the function, and no code is given here.
Ajax XML processing
You still use the function in the previous section to create the XMLHttpRequest object, where you don't write code. The Ajaxrequest function to send the request is also simpler:
The code is as follows
Copy Code
function Ajaxrequest () {var options = {URL: ' Ajax/ajaxxml.xml ',Listener:callb
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.