Search

'HTTP'에 해당되는 글 2건

  1. 2013.11.29 Delphi - Http POST call
  2. 2013.04.01 Java - Get방식 Http 호출

Delphi - Http POST call

Programming/Delphi 2013.11.29 10:18 Posted by 파란크리스마스

Delphi - Http POST call

DelphiHttpPostCall.7z

procedure TForm1.Button1Click(Sender: TObject);
var
  sl : TStringList;
  ResponseStream: TMemoryStream;
  resultBytes: TBytes;
begin
  sl := TStringList.Create;
  ResponseStream := TStringStream.Create;
  try
    IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
    sl.Add('id=' + Edit2.Text);
    IdHTTP1.Post(Edit1.Text, sl, ResponseStream);
    ResponseStream.Position := 0;

    SetLength(resultBytes, ResponseStream.Size);
    ResponseStream.ReadBuffer(resultBytes[0], Length(resultBytes));

    Memo1.Lines.Text := TEncoding.UTF8.GetString(resultBytes);
  finally
    sl.Free;
    ResponseStream.Free;
  end;
end;
신고
TAG Delphi, HTTP, post

Java - Get방식 Http 호출

Programming/Java 2013.04.01 21:17 Posted by 파란크리스마스
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

public class HttpGetCall {

	public static void main(String[] args) throws Exception {
		URL url = new URL("http://naver.com");
		InputStream is = url.openStream();

		BufferedReader inFile = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while( (line = inFile.readLine()) != null ) {
            System.out.println(line);
        }
		is.close();
	}
}
신고
TAG GET, HTTP, Java, URL


 

티스토리 툴바