내가 보려고 정리하는/Spring

웹 : 비동기(2), R.head : 0303

보동이용용 2023. 3. 3. 13:52
반응형

 

클라이언트가 원하는 조건이 들어있는 Accept Headers

서버는 클라이언트가 원하는 정보를 주어야한다. 

HttpServlet 객체가 가지고 있는 request에서 얻을 수 있다. 고로, request는 get을 많이 가지고 있다.

MIME이 여러개인 이유? 우선순위. 1없으면 2, 2없으면, 3...

응답데이터 중에서 data-type은 이 Accept의 종류를 설정하는 것이었다.

내 브라우저 정

Windows : os

Chrome

AppleWebKit : 브라우저의 랜더링 엔진. 서버사이드의 글을 번역하는 엔진

Sarafi 

 

유저에이전트 : 클라이언트의 접속 도구가 모바일인지 컴인지 확인하는 도구

User agent 바꿔보기

==> 클라이언트의 요청은 검증이 필요하다 ㅠㅠ 

그런데 이거 사용해본 적이 있는가? 아니요! >> request는 클라이언트가 의도하지 않는 요청이다.

>> 비의도적 메타데이타 

 

유저에이전트 -> copy value

Crome

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Edge

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57

 

Mozilla/5.0 (Windows NT 10.0; Win64; x64)  ==> 모바일인지 데스트탑인지 확인 가능

 

 

<form>
	<input type="text" name="param1" value="value1" />
	<input type="number" name="param2" value="1024" />
	<input type="submit" value="전송" />
</form>

Query String을 번역하여 주는 Payload

String으로 파라미터가 올 수 밖에 없는 이유==> Query String으로 오기 때문에 . String

get방식으로 보낼 때. body가 없어서 line에 담아 보냄.

<form method="post">
	<input type="text" name="param1" value="value1" />
	<input type="number" name="param2" value="1024" />
	<input type="submit" value="전송" />
</form>

<form method="post">
	<input type="text" name="param1" value="한글" />
	<input type="number" name="param2" value="1024" />
	<input type="submit" value="전송" />
</form>

 

Content-Type:
application/x-www-form-urlencoded
 
enctype="application/x-www-form-urlencoded"
 
enctype="multipart/form-data"   >> 폼의 입력데이터만큼 파트를 생성하겠다.
<form method="post" enctype="multipart/form-data">
	<input type="text" name="param1" value="한글" />
	<input type="number" name="param2" value="1024" />
	<input type="submit" value="전송" />
</form>

 

 

 

파트와 파트 사이를 특수한 무언가로 나누겠다. 파트형태로 전송

↓↓↓

GET PARAMETER사용불가.

 

 

 

 

<%=request.getRequestURL() %>
<%=request.getRequestURI() %>

<%=request.getMethod() %>

↓↓↓

http://localhost/WebStudy01/06/requestDesc.jsp
/WebStudy01/06/requestDesc.jsp
GET

<%=request.getHeader("Accept") %>

↓↓↓

text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

reqeust와 response의 타입이 다른 예 -> 실패


Set<String> set = new HashSet<>();
	set.add("value1");
	set.add("value2");
	// collection view : iterator, enumeration
	//진짜 순서가 없는 컬렉션 set을 가지고 와서 순서가 있는 것처럼 가짜로 만든 것 
	Iterator<String> it = set.iterator(); 
	while(it.hasNext()){
		 it.next();
	}


Accept Header

간과하지 말거라!

<h4> 요청 헤더의 종류 </h4>
<table>
<thead>
</thead>
<tbody>
	<tr>
		<th>헤더이름</th>
		<th>헤더값</th>
	</tr>
<%
	Enumeration<String> en = request.getHeaderNames();
	String headerptrn = "<tr><td>%s</td><td>: %s</td></tr>";
	while(en.hasMoreElements()){
		String headerName = en.nextElement();
		String headerValue = request.getHeader(headerName);
		out.println(String.format(headerptrn, headerName, headerValue));
	}
%>
</tbody>
</table>

 

// Accept request header/Content-Type response header 결정 속성.
// json : application/json, xml : application/xml, html : text/html, text : text/plain, script : application[text]/java

 

<<리플렉션!!!!>>

리스펀스 영역의 패키징 방

 

xml, html 모두 돔트리 구조 사용

그렇다면 jquery로 감싸서 사용할 수 있다는 결론.!

 

반응형