HTTP 요청 인 코딩 형식 및 메시지

9466 단어 통신 프로 토 콜
HTTP 가 요청 한 인 코딩 형식 은 매우 많은 데, 여기 서 주로 자주 사용 하 는 것 을 기술 합 니 다.
  • application / x - ww - form - urlencoded: 창 데이터 가 이름 / 값 으로 인 코딩 되 었 습 니 다.(기본 값).빈 칸 을 '+' 플러스 로 바 꾸 지만 특수 문자 인 코딩 은 하지 않 습 니 다.
  • multipart / form - data: 창 데 이 터 는 하나의 메시지 로 인 코딩 되 었 고 페이지 의 모든 컨트롤 은 메시지 의 일부분 에 대응 합 니 다.
  • text / plain: 창 데 이 터 는 일반 텍스트 로 인 코딩 되 며 컨트롤 이나 형식 문 자 는 포함 되 어 있 지 않 습 니 다.
  • JSON: 일반 텍스트 형식 으로 인 코딩 을 하고 그 형식 은 JSON 입 니 다.

  • 현재 HTML 코드 는 다음 과 같 습 니 다. 속성 enctype 의 값 으로 Content - Type 을 구분 합 니 다.
    <form action="http://localhost:8080" method="post" enctype="application/x-www-form-urlencoded">
    
        <input type="text" name="userName" value="zhan gsan"/>
        <input type="text" name="password" value="password"/>
        <input type="file" name="resultFile" />
        <input type="submit" value="submit"/>
    
    form>

    Content - type 이 다른 값 일 때 메시지 결 과 는 다음 과 같 습 니 다.
    Content-Type=application/x-www-form-urlencoded
    브 라 우 저 는 x - ww - form - urlencoded 의 인 코딩 방식 으로 form 데 이 터 를 문자열 (name 1 = value 1 & name 2 = value 2...) 로 변환 한 다음 이 문자열 append 를 url 뒤에 사용 합 니까?분할, 이 새로운 url 을 불 러 옵 니 다.action 이 post 일 때 브 라 우 저 는 form 데 이 터 를 http body 에 밀봉 한 다음 server 에 보 냅 니 다.
    POST / HTTP/1.1
    Host: localhost:8080
    Connection: keep-alive
    Content-Length: 62
    Cache-Control: max-age=0
    Upgrade-Insecure-Requests: 1
    Origin: null
    Content-Type: application/x-www-form-urlencoded
    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
    Accept-Encoding: gzip, deflate, br
    Accept-Language: zh-CN,zh;q=0.9
    
    userName=zhan+gsan&password=password&resultFile=dddddddddd.vlx

    Content-Type=multipart/form-data
    브 라 우 저 는 전체 폼 을 컨트롤 단위 로 나 누고 각 부분 에 Content - Disposition (form - data 또는 file), name (컨트롤 name) 등 정 보 를 추가 하고 분할 문자 (boundary) 를 추가 합 니 다.이 메시지 의 분할 부 호 는: boundary = - webKitForm Boundary s70zFPQBqcgHeMy 9 입 니 다.
    POST / HTTP/1.1
    Host: localhost:8080
    Connection: keep-alive
    Content-Length: 659
    Cache-Control: max-age=0
    Upgrade-Insecure-Requests: 1
    Origin: null
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundarys70zFPQBqcgHeMy9
    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
    Accept-Encoding: gzip, deflate, br
    Accept-Language: zh-CN,zh;q=0.9
    
    ------WebKitFormBoundarys70zFPQBqcgHeMy9
    Content-Disposition: form-data; name="userName"
    
    zhan gsan
    ------WebKitFormBoundarys70zFPQBqcgHeMy9
    Content-Disposition: form-data; name="password"
    
    password
    ------WebKitFormBoundarys70zFPQBqcgHeMy9
    Content-Disposition: form-data; name="resultFile"; filename="dddddddddd.vlx"
    Content-Type: application/octet-stream
    
    {"nodes":[{"name":"11111","image":"theme/gast/ren.png","entityId":"1000001"},{"name":"5555","image":"theme/gast/ren.png","entityId":"1000001"}],"edges":[{"source":"11111","target":"5555","relation":"ssss","count":"1","currentExtDepth":"1"}]}
    ------WebKitFormBoundarys70zFPQBqcgHeMy9--

    Content-Type=text/plain
    POST / HTTP/1.1
    Host: localhost:8080
    Connection: keep-alive
    Content-Length: 66
    Cache-Control: max-age=0
    Upgrade-Insecure-Requests: 1
    Origin: null
    Content-Type: text/plain
    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
    Accept-Encoding: gzip, deflate, br
    Accept-Language: zh-CN,zh;q=0.9
    
    userName=zhan gsan
    password=password
    resultFile=dddddddddd.vlx

    좋은 웹페이지 즐겨찾기