C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[64747] Re:IndyHTTPServer 질문. --------- 자답!~
영악한녀석 [akrnldytpq] 1948 읽음    2011-07-04 18:58
Get  이벤트에서 브라우저가 지원하는 문서의 타입을 설정해 주었어야 하네요 ㅠㅠ
그래야 HTTP 프로토콜에 따라 리소스 요청 태그를 만났을 때 재요청을 하더군요 ㅋㅋ
아무것도 모르고 삽질만 하니 많이 힘들었숨돵 ㅠ

void __fastcall TForm1::IdHTTPServer1CommandGet(TIdPeerThread *AThread, TIdHTTPRequestInfo *RequestInfo, TIdHTTPResponseInfo *ResponseInfo)
{
    AnsiString command;
    TMemoryStream *stream = new TMemoryStream();

    command = RequestInfo->Document;

    ResponseInfo->RawHeaders->Clear();
    ResponseInfo->RawHeaders->Add( "Cache-Control: no-store, no-cache, must-revalidate" );
    ResponseInfo->RawHeaders->Add( "Cache-Control: post-check=0, pre-check=0" );
    ResponseInfo->RawHeaders->Add( "Pragma: no-cache" );

    if(!command.AnsiCompare("/"))
    {
        ResponseInfo->ContentType = "text/xml";              // 이부분~
        stream->LoadFromFile("cds.xml");
    }
    else if(!command.AnsiCompare("/TITLE.JPG"))
    {
        stream->LoadFromFile("TITLE.JPG");
        ResponseInfo->ContentType = "image/jpeg";              // 이부분~
        ResponseInfo->FreeContentStream = true;
    }
    else if(!command.AnsiCompare("/cds.xsl"))
    {
        ResponseInfo->ContentType = "text/xsl";              // 이부분~
        stream->LoadFromFile("cds.xsl");
    }

    ResponseInfo->ResponseNo = 200;
    ResponseInfo->ContentStream = stream;
}
//---------------------------------------------------------------------------




영악한녀석  님이 쓰신 글 :
: 웹에 대해서 잘 모르다 보니 삽질을 많이 해서 너무 지쳤습니다. ㅠㅠ
: 고수님들께 질문좀 여쭐께요.
:
: IndyHTTPServer 가지고 웹서버를 하나 맨들었습니다.
:
: void __fastcall TForm1::IdHTTPServer1CommandGet(TIdPeerThread *AThread, TIdHTTPRequestInfo *RequestInfo, TIdHTTPResponseInfo *ResponseInfo)
: {
:     AnsiString command;
:
:     command = RequestInfo->Document;
:
:     if(!command.AnsiCompare("/"))
:     {
:         TMemoryStream *stream = new TMemoryStream();
:
:         stream->LoadFromFile("cds.xml");
:
:         ResponseInfo->ResponseNo = 200;
:         ResponseInfo->ContentStream = stream;
:     }
: }
:
: 이렇게 get 이벤트에서 xml을 줍니다. 아래는 xml 내용입니다.
:
: <?xml version="1.0" encoding="euc-kr" ?>
:
: <?xml-stylesheet type="text/xsl" href="cds.xsl" ?>
: <cds>
:     <disc>
:             <artist genre="individual">Rammstein</artist>
:             Sehnsucht
:             <tracks>               
:                 <track num="1">Sehnsucht</track>
:                 <track num="2">Engel</track>
:                 <track num="3">Tier</track>
:                 <track num="4">Du Hast</track>
:                 <track num="5">Buck Dich</track>
:             </tracks>
:             <price>$12.99</price>
:     </disc>
:     <disc>
:             <artist genre="band">Two Tone Shoe</artist>
:             Resoled & More
:             <tracks>               
:                 <track num="1">Brothers</track>
:                 <track num="2">Medichine</track>
:                 <track num="3">Paper Bag</track>
:                 <track num="4">Troopy's Blues</track>
:                 <track num="5">Jack's Jam</track>
:                 <track num="6">Believe</track>
:             </tracks>
:             <price>$10.99</price>
:     </disc>
: </cds>
:
:
: 당연히 cds.xsl 파일이 없으니 브라우저에 띄울때 제가 원하는 모양으로 안나오더라구요..
: 어떻게 해야 해결 될까요??
:
: 여기서 하나 더 추가 질문.. 만약 xsl 파일에 이미지가 올려져 있으면 브라우저에 이미지도 나와야 하는데 그 이미지는 어떻게 같이 보내야 하나요??
:
: 시원하게 해결책좀 알려주실 선배님~~ 미리 감사합니다~~

+ -

관련 글 리스트
64715 IndyHTTPServer 질문. 영악한녀석 1119 2011/06/29
64747     Re:IndyHTTPServer 질문. --------- 자답!~ 영악한녀석 1948 2011/07/04
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.